Skip to content

Commit

Permalink
Add backlinks to notes & posts. Css & filename updates.
Browse files Browse the repository at this point in the history
Add backlinks both via plugin & via layouts (notes, single, and single-nobacklinks layouts).
  • Loading branch information
ryan-p-randall committed Jan 16, 2024
1 parent 066a2f8 commit 24ea61e
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 25 deletions.
4 changes: 2 additions & 2 deletions _data/ui-text.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ en: &DEFAULT_EN
skip_content : "Skip to content"
skip_footer : "Skip to footer"
page : "Page"
pagination_previous : "Newer" # "Previous"
pagination_next : "Older" # "Next"
pagination_previous : "Previous"
pagination_next : "Next"
breadcrumb_home_label : "Home"
breadcrumb_separator : "/"
menu_label : "Toggle menu"
Expand Down
2 changes: 1 addition & 1 deletion _includes/notes_graph.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions _layouts/note.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h2 id="reading-details">Details</h2>
<label style="margin-top: -1.4em; margin-bottom: 0em;">Progress:</label> <progress value="{{ page.progress_current }}" max="{{ page.progress_max }}">{{ page.progress_current }} pages</progress>
{% endif %}

{% comment %}
<aside style="font-size: 0.9em;">
<h2 id="backlinks" style="margin-bottom: 1em">Other places I mention this note <!-- Notes mentioning this note--></h2>
{% if page.backlinks.size > 0 %}
Expand Down Expand Up @@ -74,6 +75,7 @@ <h2 id="note-info">Note Info</h2>
</div>
</aside>
</div>
{% endcomment %}
</article>

<hr>
Expand Down
115 changes: 115 additions & 0 deletions _layouts/single-no-backlinks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
layout: default
---

{% if page.header.overlay_color or page.header.overlay_image or page.header.image %}
{% include page__hero.html %}
{% elsif page.header.video.id and page.header.video.provider %}
{% include page__hero_video.html %}
{% endif %}

{% assign breadcrumbs_enabled = site.breadcrumbs %}
{% if page.breadcrumbs != null %}
{% assign breadcrumbs_enabled = page.breadcrumbs %}
{% endif %}
{% if page.url != "/" and breadcrumbs_enabled %}
{% unless paginator %}
{% include breadcrumbs.html %}
{% endunless %}
{% endif %}

<div id="main" role="main">
{% include sidebar.html %}
<article class="page h-entry" itemscope itemtype="https://schema.org/CreativeWork">
{% if page.title %}<meta itemprop="headline" content="{{ page.title | markdownify | strip_html | strip_newlines | escape_once }}">{% endif %}
{% if page.excerpt %}<meta itemprop="description" content="{{ page.excerpt | markdownify | strip_html | strip_newlines | escape_once }}">{% endif %}
{% if page.date %}<meta itemprop="datePublished" content="{{ page.date | date_to_xmlschema }}">{% endif %}
{% if page.last_modified_at %}<meta itemprop="dateModified" content="{{ page.last_modified_at | date_to_xmlschema }}">{% endif %}

<div class="page__inner-wrap">
{% unless page.header.overlay_color or page.header.overlay_image %}
<header>
{% if page.title %}<h1 id="page-title" class="page__title p-name" itemprop="headline">
<a href="{{ page.url | absolute_url }}" class="u-url" itemprop="url">{{ page.title | markdownify | remove: "<p>" | remove: "</p>" }}</a>
</h1>{% endif %}
{% include page__meta.html %}
</header>
{% endunless %}

<section class="page__content e-content" itemprop="text">
{% if page.toc %}
<aside class="sidebar__right {% if page.toc_sticky %}sticky{% endif %}">
<nav class="toc">
<header><h2 class="nav__title"><i class="fas fa-{{ page.toc_icon | default: 'file-alt' }}"></i> {{ page.toc_label | default: site.data.ui-text[site.locale].toc_label | default: "On this page" }}</h2></header>{% comment %}these were h4{% endcomment %}
{% include toc.html sanitize=true html=content h_min=1 h_max=6 class="toc__menu" skip_no_ids=true %}
</nav>
</aside>
{% endif %}
{% comment %}{% include light-mode-only-notice.html %}{% endcomment %}
{{ content }}
{% if page.categories contains "notes" %}
{% include notes-index-mention.html %}
{% else %}
{% endif %}
{% if page.link %}<div><a href="{{ page.link }}" class="btn btn--primary">{{ site.data.ui-text[site.locale].ext_link_label | default: "Direct Link" }}</a></div>{% endif %}
</section>

{% comment %}{% endcomment %}
<aside style="font-size: 0.9em;">
<h2 id="bonus-info">Bonus Info</h2>
<h3 id="page-info">Page Info</h3>
<div style="display: grid; grid-gap: 1em; grid-template-columns: repeat(2, 0.5fr);">
<div class="backlink-box">
<a class="internal-link"
href="{{ site.github.repository_url }}/commits/develop/{{ page.relative_path }}">View page revision history</a></div>
<div class="backlink-box">
<a class="internal-link"
href="{{ site.github.repository_url }}/blob/develop/{{ page.relative_path }}">View page source</a></div>
</div>
</aside>{% comment %}{% endcomment %}

<footer class="page__meta">
{% if site.data.ui-text[site.locale].meta_label %}
<h4 class="page__meta-title">{{ site.data.ui-text[site.locale].meta_label }}</h4>
{% endif %}
{% include article_author.html %}
{% include page__taxonomy.html %}
{% include page__date.html %}
</footer>

{% if page.share %}{% include social-share.html %}{% endif %}

{% include post_pagination.html %}
</div>

{% if jekyll.environment == 'production' and site.comments.provider and page.comments %}
{% include comments.html %}
{% endif %}
</article>

{% comment %}<!-- only show related on a post page when `related: true` -->{% endcomment %}

{% if page.id and page.related and site.related_posts.size > 0 %}
<div class="page__related">
<h2 class="page__related-title">{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}</h2>
<div class="grid__wrapper">
{% for post in site.related_posts limit:4 %}
{% include archive-single.html type="grid" %}
{% endfor %}
</div>
</div>
{% comment %}<!-- otherwise show recent posts if no related when `related: true` -->{% endcomment %}
{% elsif page.id and page.related %}
<div class="page__related">
<h2 class="page__related-title">{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}</h2>
<div class="grid__wrapper">
{% for post in site.posts limit:4 %}
{% if post.id == page.id %}
{% continue %}
{% endif %}
{% include archive-single.html type="grid" %}
{% endfor %}
</div>
</div>
{% endif %}
</div>
67 changes: 51 additions & 16 deletions _layouts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,57 @@
{% endif %}
{% if page.link %}<div><a href="{{ page.link }}" class="btn btn--primary">{{ site.data.ui-text[site.locale].ext_link_label | default: "Direct Link" }}</a></div>{% endif %}
</section>

<footer class="page__meta">
{% if site.data.ui-text[site.locale].meta_label %}
<h4 class="page__meta-title">{{ site.data.ui-text[site.locale].meta_label }}</h4>
{% endif %}
{% include article_author.html %}
{% include page__taxonomy.html %}
{% include page__date.html %}
</footer>

{% if page.share %}{% include social-share.html %}{% endif %}

{% include post_pagination.html %}
</div>

{% if jekyll.environment == 'production' and site.comments.provider and page.comments %}
{% comment %}{% endcomment %}
<aside style="font-size: 0.9em; margin-top: 1em;">
<h2 id="bonus-info">Bonus Info</h2>
<h3 id="backlinks-page" style="margin-bottom: 1em">Other places I mention this page <!-- Notes mentioning this note--></h3>
{% if page.backlinks.size > 0 %}
<div style="display: grid; grid-gap: 1em; grid-template-columns: repeat(2, 0.5fr);">
{% for backlink in page.backlinks %}
{% if backlink.dir != "/_posts/" %}
<div class="backlink-box">
<a class="internal-link"
href="{{ site.baseurl }}{{ backlink.url }}{%- if site.use_html_extension -%}.html{%- endif -%}">{{
backlink.title }}</a><br>
<div style="font-size: 0.9em; margin: 0;">{{ backlink.excerpt | markdownify | truncatewords: 20 }}</div> <!-- initially was backlink.excerpt | strip_html | truncatewords: 20 -->
</div>
{% endif %}
{% endfor %}
</div>
{% else %}

<div style="font-size: 0.9em">
<p>
I don't mention this page elsewhere… <strong>yet</strong>.<!-- There are no notes linking to this note. -->
</p>
</div>
{% endif %}
<h3 id="page-info">Page Info</h3>
<div style="display: grid; grid-gap: 1em; grid-template-columns: repeat(2, 0.5fr);">
<div class="backlink-box">
<a class="internal-link"
href="{{ site.github.repository_url }}/commits/develop/{{ page.relative_path }}">View page revision history</a></div>
<div class="backlink-box">
<a class="internal-link"
href="{{ site.github.repository_url }}/blob/develop/{{ page.relative_path }}">View page source</a></div>
</div>
</aside>{% comment %}{% endcomment %}
</section>
<footer class="page__meta">
{% if site.data.ui-text[site.locale].meta_label %}
<h4 class="page__meta-title">{{ site.data.ui-text[site.locale].meta_label }}</h4>
{% endif %}
{% include article_author.html %}
{% include page__taxonomy.html %}
{% include page__date.html %}
</footer>

{% if page.share %}{% include social-share.html %}{% endif %}

{% include post_pagination.html %}
</div>

{% if jekyll.environment == 'production' and site.comments.provider and page.comments %}
{% include comments.html %}
{% endif %}
</article>
Expand Down
2 changes: 1 addition & 1 deletion _pages/about.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
permalink: /about/
title: "About"
layout: single
layout: single-no-backlinks
#header:
# image: /assets/images/pocket-notebooks.jpg
# image_description: "ryan's pocket notebooks"
Expand Down
9 changes: 5 additions & 4 deletions _plugins/bidirectional_links_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def generate(site)
graph_nodes = []
graph_edges = []

all_notes = site.collections['notes'].docs
# all_pages = site.pages
all_posts = site.posts.docs
all_notes = site.collections['notes'].docs + site.posts.docs
all_pages = site.pages
# all_posts = site.posts.docs

all_docs = all_notes + all_posts # + all_pages
all_docs = all_notes + all_pages # all_posts + all_pages

link_extension = !!site.config["use_html_extension"] ? '.html' : ''

Expand Down Expand Up @@ -75,6 +75,7 @@ def generate(site)
end

# Identify note backlinks and add them to each note
# all_docs.each do |current_note|
all_notes.each do |current_note|
# Nodes: Jekyll
notes_linking_to_current_note = all_docs.filter do |e|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Weekly Assemblage for 2024 Week WW
title: Weekly Assemblage for 2024 Week 02
modified:
categories: [weekly-assemblage]
excerpt: 'RSS reading; _Author, Author_ and A.I.; and Site Refinements of the Week.'
Expand Down
4 changes: 4 additions & 0 deletions _sass/minimal-mistakes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@
.nav__list label {
color: $text-color;
border: 1px solid $primary-color;
}

.backlink-box p {
margin-bottom: 0px !important;
}
13 changes: 13 additions & 0 deletions assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,17 @@ summary:focus {

h1, h2, h3, h4, h5, h6 {
margin: 1em 0 0.5em;
}

.littlefoot {
--popover-background-color: #21262f !important;
--popover-border: 1px solid $border-color;
--popover-text-color: #eaeaea !important;
--popover-font-size: $doc-font-size;
}

.pagination {
margin-top: 0em;
padding-top: 0em;
padding-bottom: 1em;
}

0 comments on commit 24ea61e

Please sign in to comment.