mirror of
https://github.com/gcushen/hugo-academic.git
synced 2025-07-23 10:00:52 +02:00
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
This commit is contained in:
parent
c2e9a799f7
commit
971f297e46
8 changed files with 87 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
4
modules/blox-tailwind/assets/dist/wc.min.css
vendored
4
modules/blox-tailwind/assets/dist/wc.min.css
vendored
File diff suppressed because one or more lines are too long
|
@ -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'
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
- id: related
|
||||
translation: Related
|
||||
|
||||
- id: backlinks
|
||||
translation: Backlinks
|
||||
|
||||
- id: minute_read
|
||||
translation: min read
|
||||
|
||||
|
|
|
@ -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 }}
|
|
@ -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 }}
|
|
@ -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 }}
|
|
@ -38,6 +38,8 @@
|
|||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{ partial "components/backlinks" . }}
|
||||
|
||||
{{ partial "functions/get_hook" (dict "hook" "toc-end" "context" .) }}
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue