From d22fcbef3553a255cb2e1ef49b8d889e46ddcc33 Mon Sep 17 00:00:00 2001
From: Alan M <17537489+Am3ra@users.noreply.github.com>
Date: Sun, 31 Jan 2021 01:38:24 -0600
Subject: [PATCH] Update generator to include baseurl.
One of the breaking errors that I fixed in my install of this great repo was that all links generated by the ruby script didn't take into account the baseurl specified in the config file.
This ruby file corrects the error, although in the paths it might add one '/' too many. This hasn't caused me any issues, but should be considered.
---
_plugins/bidirectional_links_generator.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/_plugins/bidirectional_links_generator.rb b/_plugins/bidirectional_links_generator.rb
index 1efa1eb..90fe62a 100644
--- a/_plugins/bidirectional_links_generator.rb
+++ b/_plugins/bidirectional_links_generator.rb
@@ -24,28 +24,28 @@ class BidirectionalLinksGenerator < Jekyll::Generator
# [[A note about cats|this is a link to the note about cats]]
current_note.content = current_note.content.gsub(
/\[\[#{title_from_filename}\|(.+?)(?=\])\]\]/i,
- "\\1"
+ "\\1"
)
# Replace double-bracketed links with label using note filename
# [[cats|this is a link to the note about cats]]
current_note.content = current_note.content.gsub(
/\[\[#{note_potentially_linked_to.data['title']}\|(.+?)(?=\])\]\]/i,
- "\\1"
+ "\\1"
)
# Replace double-bracketed links using note title
# [[a note about cats]]
current_note.content = current_note.content.gsub(
/\[\[(#{note_potentially_linked_to.data['title']})\]\]/i,
- "\\1"
+ "\\1"
)
# Replace double-bracketed links using note filename
# [[cats]]
current_note.content = current_note.content.gsub(
/\[\[(#{title_from_filename})\]\]/i,
- "\\1"
+ "\\1"
)
end
@@ -73,7 +73,7 @@ class BidirectionalLinksGenerator < Jekyll::Generator
# Nodes: Graph
graph_nodes << {
id: note_id_from_note(current_note),
- path: "#{current_note.url}#{link_extension}",
+ path: "#{site.baseurl}#{current_note.url}#{link_extension}",
label: current_note.data['title'],
} unless current_note.path.include?('_notes/index.html')