maximevaillancourt / digital-garden-jekyll-template

Start your own digital garden using this Jekyll template 🌱
https://digital-garden-jekyll-template.netlify.app/
Other
985 stars 755 forks source link

basic jekyll question #179

Open omarcostahamido opened 1 year ago

omarcostahamido commented 1 year ago

this is me not knowing enough about jekyll.

I have made a new collection named _database where i will host several pages. Now they are linked using the [[ ]] technique, which works just fine on obsidian, but the problem is... they don't work on the live website! I've added the collection on _config.yml as such:

database:
    output: true

but still no good. they just show up as [[ not linked yeah? ]] with the brackets showing! (ugly much).

I've experimented enough (naively so, perhaps) to know that if I just make it a category, as in make the pages inside a database folder instead of a _database folder, it just works. 🤯 Now the problem is that I do need the collection feature because I want to be able to iterate through its items...

Sorry for noise. I appreciate if someone who knows their way around jekyll and this template could help me 🙏

Best,

omarcostahamido commented 1 year ago

to start hinting at an answer to myself, i think all the magic is on https://github.com/maximevaillancourt/digital-garden-jekyll-template/blob/main/_plugins/bidirectional_links_generator.rb now, if only i could understand all of it...

maximevaillancourt commented 1 year ago

Your last comment is correct: ­bidirectional_links_generator.rb is indeed where the magic happens, specifically on this line:

https://github.com/maximevaillancourt/digital-garden-jekyll-template/blob/40101f01a1b61a68477ef70952c0f529ab33c82c/_plugins/bidirectional_links_generator.rb#L7

The above works because I defined a collection named notes here:

https://github.com/maximevaillancourt/digital-garden-jekyll-template/blob/40101f01a1b61a68477ef70952c0f529ab33c82c/_config.yml#L30-L33

If you want to add a collection named database, try changing the above to this:

 collections: 
   notes: 
     output: true 
     permalink: /:slug 
   database: 
     output: true 
     permalink: /database/:slug 

Then, ­in bidirectional_links_generator.rb, update line 7 (from the first code snippet) to this:

all_notes = site.collections['notes'].docs + site.collections['datbase'].docs

Good luck!

kenandotfyi commented 8 months ago

Hey Maxime, Extending on the question, regarding the backlinks:

I am not quite familiar with Ruby syntax and I've been trying to implement my backlinks algorithm in JS. As far as I understood from your code, you basically dump all the posts to all_notes and then scan this dump for the current note.url for every single note and put them in notes_linking_to_current_note for each note.

https://github.com/maximevaillancourt/digital-garden-jekyll-template/blob/40101f01a1b61a68477ef70952c0f529ab33c82c/_plugins/bidirectional_links_generator.rb#L77-L81

Afterwards, you write it to that note's frontmatter with:

current_note.data['backlinks'] = notes_linking_to_current_note

Am I correct? _I assume frontmatter of markdown files are stored in currentnote.data object.

Thanks in advance!