Compare commits

..

2 commits

Author SHA1 Message Date
George Cushen
934246c45b starters: update 2024-05-18 21:17:09 +01:00
George Cushen
971f297e46 feat: add support for backlinks
Enabled by default in right sidebar. Can be disabled with `backlinks: false` in front matter.

See https://github.com/gohugoio/hugo/issues
2024-05-18 21:14:14 +01:00
31 changed files with 113 additions and 25 deletions

View file

@ -80,3 +80,7 @@
z-index: -1;
display: block;
}
.backlink {
@apply text-xs font-medium text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 contrast-more:text-gray-800 contrast-more:dark:text-gray-50;
}

File diff suppressed because one or more lines are too long

View file

@ -1,13 +1,20 @@
markup:
defaultMarkdownHandler: goldmark
goldmark:
renderHooks:
link:
# Process backlinks hook
enableDefault: true
renderer:
# Render HTML in Markdown
unsafe: true
parser:
# Support Latex math(?)
attribute:
block: true
title: true
extensions:
# Support Latex math
passthrough:
enable: true
delimiters:
@ -21,7 +28,18 @@ markup:
- \)
- - $
- $
extras:
# Enable subscript, superscript, and highlighting with ~,^, and == wrappers
insert:
enable: false
mark:
enable: true
subscript:
enable: true
superscript:
enable: true
highlight:
# Enable code highlighting
codeFences: true
noHl: false
lineNumbersInTable: false
@ -31,14 +49,16 @@ markup:
startLevel: 2
endLevel: 3
minify:
minifyOutput: true
tdewolff:
html:
keepComments: true
keepSpecialComments: true
sitemap:
changefreq: weekly
module:
hugoVersion:
min: '0.122.0'
min: '0.126.0'
extended: true
imports:
- path: github.com/HugoBlox/hugo-blox-builder/modules/blox-analytics
@ -62,6 +82,14 @@ security:
getenv:
- ^HUGO_
- ^WC_
- ^HB_
outputFormats:
backlinks:
mediaType: application/json
baseName: backlinks
isPlainText: true
notAlternative: true
weight: 1
params:
locale:
date_format: 'Jan 2, 2006'

View file

@ -26,6 +26,9 @@
- id: related
translation: Related
- id: backlinks
translation: Backlinks
- id: minute_read
translation: min read

View file

@ -0,0 +1,18 @@
{{- $u := urls.Parse .Destination -}}
{{- if or $u.IsAbs (strings.HasPrefix $u.String "#") }}
{{- /* do nothing */}}
{{- else }}
{{- with .PageInner.GetPage (strings.TrimPrefix "./" $u.Path) }}
{{- $source := dict
"date" ($.Page.Date.UTC.Format "2006-01-02T15:04:05-07:00")
"linkTitle" $.Page.LinkTitle
"permalink" $.Page.Permalink
"relPermalink" $.Page.RelPermalink
"section" $.Page.Section
"title" $.Page.Title
"type" $.Page.Type
}}
{{- $el := dict "source" $source "target" .RelPermalink }}
{{- site.Home.Store.Add "backlinks" (slice $el) }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,9 @@
{{- $debug := false }}
{{- range site.Pages }}
{{- $noop := .WordCount }}
{{- end }}
{{- if $debug }}
{{- jsonify (dict "indent" " ") (.Store.Get "backlinks") }}
{{- else }}
{{- jsonify (dict "indent" " ") (dict "comment" "This file is intentionally empty.") }}
{{- end }}

View file

@ -0,0 +1,20 @@
{{ $show_backlinks := .Params.backlinks | default true }}
{{ if $show_backlinks }}
{{- $debug := false }}
{{- $backlinks := site.Home.Store.Get "backlinks" | uniq }}
{{- with (where $backlinks "target" .RelPermalink) }}
<div class="backlinks">
<div class="mb-1 font-semibold tracking-tight">
{{ or (T "backlinks") "Backlinks" }}
</div>
<ul>
{{- range (sort . "source.linkTitle" "asc") }}
<li><a href="{{ .source.relPermalink }}" class="backlink">{{ .source.linkTitle }}</a></li>
{{- end }}
</ul>
</div>
{{- end }}
{{- if $debug }}
<pre>{{ jsonify (dict "indent" " ") $backlinks }}</pre>
{{- end }}
{{ end }}

View file

@ -38,6 +38,8 @@
</div>
{{- end -}}
{{ partial "components/backlinks" . }}
{{ partial "functions/get_hook" (dict "hook" "toc-end" "context" .) }}
</div>

View file

@ -1,7 +1,7 @@
name: Deploy website to GitHub Pages
env:
WC_HUGO_VERSION: '0.125.2'
WC_HUGO_VERSION: '0.126.1'
on:
# Trigger the workflow every time you push to the `main` branch

View file

@ -57,7 +57,7 @@ permalinks:
categories: '/category/:slug/'
disableAliases: true
outputs:
home: [HTML, RSS, headers, redirects]
home: [HTML, RSS, headers, redirects, backlinks]
section: [HTML, RSS]
imaging:
resampleFilter: lanczos

View file

@ -11,6 +11,10 @@ Make sure to check out [uses.tech](https://uses.tech/) for a list of everyone's
I often get asked about what software or hardware I use, so this page will serve as a living document and a place to point curious readers to when I get asked.
## Website
- [Hugo Blox](https://hugoblox.com) (see the tutorial on [Getting Started](/blog/get-started/))
## Editor + Terminal
- [Visual Studio Code](https://code.visualstudio.com/) is my current editor

View file

@ -4,5 +4,5 @@ go 1.19
require (
github.com/HugoBlox/hugo-blox-builder/modules/blox-plugin-netlify v1.1.2-0.20231125204555-f431a4a2c705
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240420214532-11a51f8e9f01
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240518201414-971f297e4612
)

View file

@ -1,2 +1,2 @@
build:
hugo_version: '0.125.2'
hugo_version: '0.126.1'

View file

@ -3,7 +3,7 @@
publish = "public"
[build.environment]
HUGO_VERSION = "0.125.2"
HUGO_VERSION = "0.126.1"
GO_VERSION = "1.21.5"
NODE_VERSION = "21.1.0"
HUGO_ENABLEGITINFO = "true"

View file

@ -1,7 +1,7 @@
name: Deploy website to GitHub Pages
env:
WC_HUGO_VERSION: '0.125.2'
WC_HUGO_VERSION: '0.126.1'
on:
# Trigger the workflow every time you push to the `main` branch

View file

@ -67,7 +67,7 @@ permalinks:
categories: '/category/:slug/'
disableAliases: true
outputs:
home: [HTML, RSS, WebAppManifest, headers, redirects]
home: [HTML, RSS, WebAppManifest, headers, redirects, backlinks]
page: [HTML]
section: [HTML, RSS]
imaging:

View file

@ -4,5 +4,5 @@ go 1.15
require (
github.com/HugoBlox/hugo-blox-builder/modules/blox-plugin-netlify v1.1.2-0.20240217212918-ae7f0c597978
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240420214532-11a51f8e9f01
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240518201414-971f297e4612
)

View file

@ -1,2 +1,2 @@
build:
hugo_version: '0.125.2'
hugo_version: '0.126.1'

View file

@ -3,7 +3,7 @@
publish = "public"
[build.environment]
HUGO_VERSION = "0.125.2"
HUGO_VERSION = "0.126.1"
HUGO_ENABLEGITINFO = "true"
[context.production.environment]

View file

@ -1,7 +1,7 @@
name: Deploy website to GitHub Pages
env:
WC_HUGO_VERSION: '0.125.2'
WC_HUGO_VERSION: '0.126.1'
on:
# Trigger the workflow every time you push to the `main` branch

View file

@ -4,5 +4,5 @@ go 1.19
require (
github.com/HugoBlox/hugo-blox-builder/modules/blox-plugin-netlify v1.1.2-0.20231108143325-448ed0e3bd2b
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240420214532-11a51f8e9f01
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240518201414-971f297e4612
)

View file

@ -1,2 +1,2 @@
build:
hugo_version: '0.125.2'
hugo_version: '0.126.1'

View file

@ -3,7 +3,7 @@
publish = "public"
[build.environment]
HUGO_VERSION = "0.125.2"
HUGO_VERSION = "0.126.1"
HUGO_ENABLEGITINFO = "true"
[context.production.environment]

View file

@ -1,7 +1,7 @@
name: Deploy website to GitHub Pages
env:
WC_HUGO_VERSION: '0.125.2'
WC_HUGO_VERSION: '0.126.1'
on:
# Trigger the workflow every time you push to the `main` branch

View file

@ -4,5 +4,5 @@ go 1.19
require (
github.com/HugoBlox/hugo-blox-builder/modules/blox-plugin-netlify v1.1.2-0.20231108143325-448ed0e3bd2b
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240420214532-11a51f8e9f01
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240518201414-971f297e4612
)

View file

@ -1,2 +1,2 @@
build:
hugo_version: '0.125.2'
hugo_version: '0.126.1'

View file

@ -3,7 +3,7 @@
publish = "public"
[build.environment]
HUGO_VERSION = "0.125.2"
HUGO_VERSION = "0.126.1"
HUGO_ENABLEGITINFO = "true"
[context.production.environment]

View file

@ -1,7 +1,7 @@
name: Deploy website to GitHub Pages
env:
WC_HUGO_VERSION: '0.125.2'
WC_HUGO_VERSION: '0.126.1'
on:
# Trigger the workflow every time you push to the `main` branch

View file

@ -4,5 +4,5 @@ go 1.19
require (
github.com/HugoBlox/hugo-blox-builder/modules/blox-plugin-netlify v1.1.2-0.20231125200520-804c70f7efb8
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240420214532-11a51f8e9f01
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.2.1-0.20240518201414-971f297e4612
)

View file

@ -1,2 +1,2 @@
build:
hugo_version: '0.125.2'
hugo_version: '0.126.1'

View file

@ -3,7 +3,7 @@
publish = "public"
[build.environment]
HUGO_VERSION = "0.125.2"
HUGO_VERSION = "0.126.1"
HUGO_ENABLEGITINFO = "true"
[context.production.environment]