marcus-grant / markipedia

My personal wikipedia made from zettelkasten notetaking system
GNU Affero General Public License v3.0
1 stars 0 forks source link

Add /tags/ page and single tag pages #37

Closed marcus-grant closed 1 year ago

marcus-grant commented 1 year ago

I have tags on every note's front matter. The route /tags/ should lead to an index of tag-pages for each tag.

Bonus, have a group by operation where a tag page can also show, other tags grouped with it.

For example:

The tag-page for b should have links to all the tags (a,c,e) since it's part of notes that have all the tags. But a should only result in (b,c).

If you can't get this done for this issue, create another one and copy this to it.

marcus-grant commented 1 year ago

Handled in commit 21a2df2

By creating a folder ./site/tags/ I created a new route /tags/ which is rendered with template ./site/tags/index.njk that renders every tag within the notes collection. It does so with a new module ./utils/tag-helpers.js that has several utility functions for manipulating collection data by tags. These helper functions are added as filters in the ./.eleventy.js configuration.

Then in the ./site/tags/index.njk tags index page uses these functions to list every tag in the collection, sorted by their count in colection item tags. Then it uses those helpers to also display how many times each tag occurs. Finally the tag index template creates a link to the route /tags/<tag-string>.

That route from the generated links will lead to a paginated tag page in ./site/tags/tag-page.js that paginates via its frontmatter. There it selects the collection, filters out special tags like note all, etc and sets up a permalink /tags/{{tag | slug}}/ from the alias tag created in the pagination frontmatter. Each tag page represents a tag that is found in the notes collection. Using the tag-helper module it will then pull up note information regarding that tag to populate a set of note links pointing to that note and within the link will be information about the note.