I'm playing with Eleventy, I've got markdown files with tags within the text (as hashtags, like here), and I would like to extract them, to add them to the tags that are recognized by Eleventy, for display and collections. I think I haven't the right words to search on the net, because I found nothing… Is my problem solvable or have I no other way than modify all my files and put tags in the frontmatter?
Eleventy 🎈 v3.0.0-beta.2
in reply to Lamecarlate • • •Lamecarlate
in reply to Eleventy 🎈 v3.0.0-beta.2 • • •Eleventy 🎈 v3.0.0-beta.2
in reply to Lamecarlate • • •HMM. I’m not sure this is doable (yet). I experimented with Computed Data 11ty.dev/docs/data-computed/ (note the warning about `tags`), the Preprocessor API 11ty.dev/docs/config-preproces… and the collections API 11ty.dev/docs/collections/#adv… using page.rawInput 11ty.dev/docs/data-eleventy-su… and I just don’t think the timing is there for any of them to accommodate this use case—sorry!
The best way forward is to file an enhancement request on GitHub to allow Computed Data to populate tags, I think.
Collections
EleventyNicolas Hoizey
in reply to Eleventy 🎈 v3.0.0-beta.2 • • •@eleventy as I already told @lamecarlate , I tried but failed, so an official solution would be great.
This doesn't work:
github.com/nhoizey/nicolas-hoi…
nicolas-hoizey.com/src/_11ty/collections/notes.js at main · nhoizey/nicolas-hoizey.com
GitHubEleventy 🎈 v3.0.0-beta.2
in reply to Nicolas Hoizey • • •@nhoizey you _could_ add your own preprocessing step to achieve this, fwiw (which I think we’re all trying to avoid).
btw just making sure you’re aware of `page.rawInput`: 11ty.dev/docs/data-eleventy-su…
Eleventy Supplied Data
EleventyNicolas Hoizey
in reply to Eleventy 🎈 v3.0.0-beta.2 • • •@eleventy my code dates from Eleventy 0.x, so I'm sure there are better ways now, such as `page.rawInput`… 😅
I guess preprocessing would be too much, indeed.
@lamecarlate
Lamecarlate
in reply to Eleventy 🎈 v3.0.0-beta.2 • • •@eleventy @nhoizey I'm reading this page, it's really interesting! Still I'm confused by the amount of data (not your fault). Can I access `page.rawInput` in a directory data file, like `posts/posts.11tydata.js`? It seems to return `undefined` when in
eleventyComputed: {
insideTags: function (data) {
console.log(data.page.rawInput);
},
}
Eleventy 🎈 v3.0.0-beta.2
in reply to Lamecarlate • • •Lamecarlate
in reply to Eleventy 🎈 v3.0.0-beta.2 • • •Eleventy 🎈 v3.0.0-beta.2
in reply to Lamecarlate • • •Lamecarlate
in reply to Eleventy 🎈 v3.0.0-beta.2 • • •Lamecarlate
in reply to Lamecarlate • • •Nicolas Hoizey
in reply to Lamecarlate • • •great!
Were you able to add these hashtags to the standard tags collection built automatically by @eleventy ?
Lamecarlate
in reply to Nicolas Hoizey • • •Nicolas Hoizey
in reply to Lamecarlate • • •I think it’s unfortunately not possible (yet?) as @eleventy said in fosstodon.org/@eleventy/113193…
Eleventy 🎈 v3.0.0-beta.2
2024-09-24 14:43:30
Eleventy 🎈 v3.0.0-beta.2
in reply to Nicolas Hoizey • • •Nicolas Hoizey
in reply to Eleventy 🎈 v3.0.0-beta.2 • • •@eleventy ok 👍
@lamecarlate
Lamecarlate
in reply to Eleventy 🎈 v3.0.0-beta.2 • • •@eleventy @nhoizey Oh, I think I misread this:
> The best way forward is to file an enhancement request on GitHub to allow Computed Data to populate tags, I think.
Sooooo, putting this little tag-in-content project in standby for now ^^' I did learn much when tinkering with rawData (regex, yay), it's obviously not for nothing. Thanks a lot for your help, it was really nice!