Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Markdown Module #33

Open
sustained opened this issue Aug 20, 2019 · 0 comments
Open

Dynamic Markdown Module #33

sustained opened this issue Aug 20, 2019 · 0 comments

Comments

@sustained
Copy link
Owner

Thoughts on extracting my weird dynamic markdown system. Because sometimes thinking out loud helps one figure out a problem.

It will probably happen as a part of this PR where I started trying to apply the dynamic markdown concept to the projects section of my site (initially it was just for my blog).


The need for generated JSON files

So, for hooks:build:before we are doing a bunch of stuff:

  • It uses library/blog.js which looks in contents/blog/posts and also does a ton of stuff:
    • Figures out the categories (a category is a directory).
    • Attaches the category metadata to the categories (_meta.md within a category folder).
    • Scrapes the tags from the YAML frontmatter for all the articles.
    • etc. etc.
  • The generated JSON is loaded by the setup-store.js plugin and ultimately ends up in the Vuex store.

All of this is necessary because there's no way for asyncData to get the data it needs.

For instance, blog tags are literally an array inside YAML front matter inside an article markdown file inside a "category" (directory). That is all a blog tag is and the only place it exists.

It's simply not possible to get e.g. "all articles that correspond to a given tag" without a bunch of pre-processing.

Now that we've extended this idea of dynamic markdown to the projects of the site it's time to try to generalise this whole concept.


Issues

Categories have articles, Projects have ... nothing.

Consider:

contents/
  blog/
    my-category/
      _meta.md
      my-post.md
  projects/
    my-project/
      project.md

There is this whole issue where we need to attach metadata to a category using a special file but that isn't necessary for a project. That is to say:

  • The stuff in the project dir IS the project.
  • The stuff in the category dir IS not the category (it is the articles).
    • (Except for the metadata file).

How can we deal with this issue?

Tags, keywords, technologies, ...

  • A blog post has many tags.

  • A tag has many blog posts.

  • A project has many keywords AND

  • A project has many languages AND

  • A project has many technologies AND

  • ... + the opposite relationships.

I want people to be able to search for e.g.:

  • "all projects written in language X"
  • "all projects using technology Y"

... so we need some kind of concept of relationships, right?

Ideally we could pass the system this data:

[
  {
    directory: "projects",
    relationships: ["technologies", "keywords", "languages"]
  },
  {
    directory: "blog",
    relationships: ["tags"]
  }
]

... and that would be it. It would generate everything for us:

  • The data to get all technologies, keywords etc. for any given project.
  • The data to get all projects for any given technology, keyword etc.

And it would dump it all in the store for us to use however we wish.

More to come later probably but that's enough for now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant