diff --git a/_includes/head.html b/_includes/head.html index cf7fc73..2cc90e6 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -11,6 +11,10 @@ + + + + {% if page.excerpt %} diff --git a/_includes/notes_graph.html b/_includes/notes_graph.html index fdf2d87..4dc4d37 100644 --- a/_includes/notes_graph.html +++ b/_includes/notes_graph.html @@ -132,8 +132,8 @@ graphWrapper.appendChild(element); const reportWindowSize = () => { - element.setAttribute("width", window.innerWidth); - element.setAttribute("height", window.innerHeight); + element.setAttribute("width", graphWrapper.getBoundingClientRect().width); + element.setAttribute("height", window.innerHeight * 0.8); }; window.onresize = reportWindowSize; diff --git a/_pages/index.md b/_pages/index.md index ff51f06..2dae936 100644 --- a/_pages/index.md +++ b/_pages/index.md @@ -13,9 +13,6 @@ Welcome, weary traveller. Take a seat, drink some water. You must be wondering w My apologies, I do forget my introductions sometimes. I am Martin Brennan, the keeper of this codex. I am a writer, and above all I enjoy writing genre fiction. I write horror, sci-fi, fantasy, western, and everything else in-between, first in longhand or at the typewriter, then processed into the devil-machine. diff --git a/_plugins/bidirectional_links_generator.rb b/_plugins/bidirectional_links_generator.rb index 2becb31..1d639b6 100644 --- a/_plugins/bidirectional_links_generator.rb +++ b/_plugins/bidirectional_links_generator.rb @@ -4,31 +4,38 @@ def generate(site) graph_nodes = [] graph_edges = [] - all_notes = site.collections['notes'].docs - all_films = site.collections['film'].docs + all_notes = site.collections["notes"].docs + all_films = site.collections["film"].docs all_pages = site.pages all_posts = site.posts all_nodes = all_notes + all_films + all_posts # defining what should be visualized in the graph all_docs = all_notes + all_pages + all_films + all_posts # ... and where bidirectional links are generated - link_extension = !!site.config["use_html_extension"] ? '.html' : '' + link_extension = !!site.config["use_html_extension"] ? ".html" : "" # Convert all Wiki/Roam-style double-bracket link syntax to plain HTML # anchor tag elements () with "internal-link" CSS class all_docs.each do |current_note| all_docs.each do |note_potentially_linked_to| - title_from_filename = File.basename( - note_potentially_linked_to.basename, - File.extname(note_potentially_linked_to.basename) - ).gsub('_', ' ').gsub('-', ' ').capitalize - - filename = File.basename( - note_potentially_linked_to.basename, - File.extname(note_potentially_linked_to.basename) - ) - - new_href = "#{site.baseurl}#{note_potentially_linked_to.url}#{link_extension}" + title_from_filename = + File + .basename( + note_potentially_linked_to.basename, + File.extname(note_potentially_linked_to.basename) + ) + .gsub("_", " ") + .gsub("-", " ") + .capitalize + + filename = + File.basename( + note_potentially_linked_to.basename, + File.extname(note_potentially_linked_to.basename) + ) + + new_href = + "#{site.baseurl}#{note_potentially_linked_to.url}#{link_extension}" anchor_tag = "\\1" # Replace double-bracketed links with label using note title @@ -45,11 +52,11 @@ def generate(site) # Replace double-bracketed links with label using note filename # [[cats|this is a link to the note about cats]] current_note.content.gsub!( - /\[\[#{note_potentially_linked_to.data['title']}\|(.+?)(?=\])\]\]/i, + /\[\[#{note_potentially_linked_to.data["title"]}\|(.+?)(?=\])\]\]/i, anchor_tag ) current_note.data["excerpt"]&.content&.gsub!( - /\[\[#{note_potentially_linked_to.data['title']}\|(.+?)(?=\])\]\]/i, + /\[\[#{note_potentially_linked_to.data["title"]}\|(.+?)(?=\])\]\]/i, anchor_tag ) @@ -67,11 +74,11 @@ def generate(site) # Replace double-bracketed links using note title # [[a note about cats]] current_note.content.gsub!( - /\[\[(#{note_potentially_linked_to.data['title']})\]\]/i, + /\[\[(#{note_potentially_linked_to.data["title"]})\]\]/i, anchor_tag ) current_note.data["excerpt"]&.content&.gsub!( - /\[\[(#{note_potentially_linked_to.data['title']})\]\]/i, + /\[\[(#{note_potentially_linked_to.data["title"]})\]\]/i, anchor_tag ) @@ -88,10 +95,7 @@ def generate(site) # Replace double-bracketed links using note filename # [[cats]] - current_note.content.gsub!( - /\[\[(#{filename})\]\]/i, - anchor_tag - ) + current_note.content.gsub!(/\[\[(#{filename})\]\]/i, anchor_tag) current_note.data["excerpt"]&.content&.gsub!( /\[\[(#{filename})\]\]/i, anchor_tag @@ -101,55 +105,53 @@ def generate(site) # At this point, all remaining double-bracket-wrapped words are # pointing to non-existing pages, so let's turn them into disabled # links by greying them out and changing the cursor - current_note.content = current_note.content.gsub( - /\[\[([^\]]+)\]\]/i, # match on the remaining double-bracket links - <<~HTML.chomp # replace with this HTML (\\1 is what was inside the brackets) - - [[ - \\1 - ]] - HTML - ) + current_note.content = + current_note + .content + .gsub(/\[\[([^\]]+)\]\]/i) do |match| + link_text = $1.split("|").last # Take the part after the pipe + <<~HTML.chomp + + #{link_text} + + HTML + end end # Identify note backlinks and add them to each note all_nodes.each do |current_note| # Nodes: Jekyll - notes_linking_to_current_note = all_notes.filter do |e| - e.content.include?(current_note.url) - end + notes_linking_to_current_note = + all_notes.filter { |e| e.content.include?(current_note.url) } # Nodes: Graph - graph_nodes << { - id: note_id_from_note(current_note), - path: "#{site.baseurl}#{current_note.url}#{link_extension}", - label: current_note.data['title'], - } unless current_note.path.include?('_notes/index.html') + unless current_note.path.include?("_notes/index.html") + graph_nodes << { + id: note_id_from_note(current_note), + path: "#{site.baseurl}#{current_note.url}#{link_extension}", + label: current_note.data["title"] + } + end # Edges: Jekyll - current_note.data['backlinks'] = notes_linking_to_current_note + current_note.data["backlinks"] = notes_linking_to_current_note # Edges: Graph notes_linking_to_current_note.each do |n| graph_edges << { source: note_id_from_note(n), - target: note_id_from_note(current_note), + target: note_id_from_note(current_note) } end end - File.write('_includes/notes_graph.json', JSON.dump({ - edges: graph_edges, - nodes: graph_nodes, - })) + File.write( + "_includes/notes_graph.json", + JSON.dump({ edges: graph_edges, nodes: graph_nodes }) + ) end def note_id_from_note(note) - note.data['title'] - .dup - .gsub(/\W+/, ' ') - .delete(' ') - .to_i(36) - .to_s + note.data["title"].dup.gsub(/\W+/, " ").delete(" ").to_i(36).to_s end end diff --git a/_sass/_style.scss b/_sass/_style.scss index e55044c..3ebe46a 100644 --- a/_sass/_style.scss +++ b/_sass/_style.scss @@ -6,10 +6,7 @@ $color-box-background: mix($color-primary, white, 4%); // $color-box-background-bold: #4e60e2; $color-box-background-bold: #45479c; $border-radius: 4px; -// $font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, -// sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol; -$font-family: Georgia, serif; -// $font-family: "Source Serif Pro", "Apple Garamond", "Baskerville", "Libre Baskerville", "Droid Serif", "Times New Roman", "Times", serif; +$font-family: "EB Garamond", "Georgia", serif; body { background-color: #fff5e6; @@ -28,7 +25,7 @@ body { } @media (min-width: 1280px) { - font-size: 1.2rem; + font-size: 1.4rem; } @media (max-width: 700px) { @@ -386,6 +383,7 @@ nav { width: 100%; padding: 10px; box-sizing: border-box; + font-family: $font-family; } }