-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
display note tags #4
Comments
Maybe a better solution would be to write a guide on adding it. |
Hi @binyamin -- I'm happy to take on this issue. |
@tannerdolby Thanks so much! By the way, I did something similar in my personal site. Also, I just remembered: with #11, could this become a search feature instead of a dedicated page? |
@binyamin I've prototyped something up based on the similar thing you did on your website. Within Note: I'm using the filter by .use(function(md) {
// Recognize Hashtag links (#tag)
md.linkify.add("#", {
validate: /^[\w-]+/,
normalize: match => {
match.url = "/notes/tag/".concat(match.raw.slice(1));
}
})
}) After studying how you created the function removeFileExtension(a) {
return a.substring(0, a.length - 3);
}
...
eleventyComputed: {
hashtags: (data) => {
const notes = data.collections.notes;
let hashtags = [];
// Search all notes for hashtags utilizing removeFrontmatter
for (const otherNote of notes) {
const noteContent = removeFrontmatter(otherNote.template.inputContent);
// Grab all hashtags from other notes
const outboundHashtags = (noteContent.match(/#(\w+)/g) || []);
const url = removeFileExtension(otherNote.inputPath);
hashtags.push({
title: otherNote.data.title,
tags: outboundHashtags,
url: `/${url}/`,
});
}
return hashtags;
}
} Where
I also created a template filename:
|
@tannerdolby Can you make this a PR, or a draft PR, so we can use GitHub's usual annotation tools?
|
@binyamin Yes I will create a PR for this.
I've been thinking about implementing search for my own site but haven't got around to it. Let me know how it goes, I'm curious to see how big the downloaded files are since the elasticlunr method is on the client-side, so the entire index of pages will be downloaded to the browser. |
In case someone want this, here is tags.11tydata.js i used ^
|
@jkarttunen That's a pretty neat idea! It'd have to wait until the tag pages actually exist, however. Can you please open another issue, so I can keep track of it? |
Use hashtags to generate lists of related notes. Each hashtag should link to the relevant list.
Example: Some of my notes include the text "#art". I want a page which lists all notes containing "#art". The page should be
/tag/art
, or something similar.Alternatives: Depending on how the search function (#11) is implemented, you could simply link all hashtags to a search query like
/search?tag=art
.The text was updated successfully, but these errors were encountered: