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

basic jekyll question #179

Open
omarcostahamido opened this issue Oct 25, 2023 · 3 comments
Open

basic jekyll question #179

omarcostahamido opened this issue Oct 25, 2023 · 3 comments

Comments

@omarcostahamido
Copy link
Contributor

omarcostahamido commented Oct 25, 2023

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
Copy link
Contributor Author

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
Copy link
Owner

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

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

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

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

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
Copy link

kenandotfyi commented Mar 15, 2024

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.

all_notes.each do |current_note|
# Nodes: Jekyll
notes_linking_to_current_note = all_notes.filter do |e|
e.content.include?(current_note.url)
end

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 current_note.data object.

Thanks in advance!

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

3 participants