backlinks generated not just as links but also as intersect in between front matter and sandpointsnamegraph

master
Marcell Mars 3 years ago
parent 8f7d9eeabe
commit c9d96eb9af

@ -1,18 +1,19 @@
{
"syllabus": "syllabi",
"curriculum": "curriculums",
"notebook": "notebooks",
"book": "books",
"journal": "journals",
"topic": "topics",
"part": "parts",
"issue": "issues",
"tab": "tabs",
"experiment": "experiments",
"session": "sessions",
"chapter": "chapters",
"article": "articles",
"note": "notes",
"annex": "annexes",
"author": "authors"
"syllabus": "syllabi",
"curriculum": "curriculums",
"notebook": "notebooks",
"book": "books",
"journal": "journals",
"topic": "topics",
"part": "parts",
"issue": "issues",
"tab": "tabs",
"experiment": "experiments",
"session": "sessions",
"chapter": "chapters",
"article": "articles",
"note": "notes",
"annex": "annexes",
"author": "authors",
"editor": "editors"
}

@ -3,6 +3,14 @@
{{ $_ := newScratch }}
{{ $debug := (slice) }}
{{ $sandnameSingular := (slice) }}
{{ $sandnamePlural := (slice) }}
{{ range $k, $v := $.Site.Data.sandpointsnamegraph }}
{{ $sandnameSingular = $sandnameSingular | append $k }}
{{ $sandnamePlural = $sandnamePlural | append $v }}
{{ end }}
{{ $pPath := "" }}
{{ range $p := .Site.RegularPages }}
{{ $pPath = printf "/%s" $p.File }}
@ -23,16 +31,22 @@
{{ end }}
{{ end }}
{{ with $authors := $p.Params.authors }}
{{ range $author := $authors }}
{{ $authorLink := printf "/author/%s" $author }}
{{ with ($_.Get $authorLink) }}
{{ $_.SetInMap $authorLink "backlinks" (uniq ((index ($_.Get $authorLink) "backlinks") | append $p)) }}
{{ $paramsKeys := (slice) }}
{{ range $k, $v := $p.Params }}
{{ $paramsKeys = $paramsKeys | append $k }}
{{ end }}
{{ $mentions := intersect $paramsKeys $sandnamePlural }}
{{ range $mention := $mentions }}
{{ range $m := index $p.Params $mention }}
{{ $mentionLink := printf "/%s/%s" (substr $mention 0 -1) $m }}
{{ with ($_.Get $mentionLink) }}
{{ $_.SetInMap $mentionLink "backlinks" (uniq ((index ($_.Get $mentionLink) "backlinks") | append $p)) }}
{{ else }}
{{ $_.SetInMap $authorLink "backlinks" (slice $p) }}
{{ end }}
{{ end }}
{{ end }}
{{ $_.SetInMap $mentionLink "backlinks" (slice $p) }}
{{ end }}
{{ end }}
{{ end }}
{{ $gp := $.GetPage $pPath }}
{{ $gpPath := printf "/%s" $gp.File }}

Loading…
Cancel
Save