backlinks generated not just as links but also as intersect in between front matter and sandpointsnamegraph
This commit is contained in:
parent
8f7d9eeabe
commit
c9d96eb9af
2 changed files with 40 additions and 25 deletions
|
@ -1,18 +1,19 @@
|
||||||
{
|
{
|
||||||
"syllabus": "syllabi",
|
"syllabus": "syllabi",
|
||||||
"curriculum": "curriculums",
|
"curriculum": "curriculums",
|
||||||
"notebook": "notebooks",
|
"notebook": "notebooks",
|
||||||
"book": "books",
|
"book": "books",
|
||||||
"journal": "journals",
|
"journal": "journals",
|
||||||
"topic": "topics",
|
"topic": "topics",
|
||||||
"part": "parts",
|
"part": "parts",
|
||||||
"issue": "issues",
|
"issue": "issues",
|
||||||
"tab": "tabs",
|
"tab": "tabs",
|
||||||
"experiment": "experiments",
|
"experiment": "experiments",
|
||||||
"session": "sessions",
|
"session": "sessions",
|
||||||
"chapter": "chapters",
|
"chapter": "chapters",
|
||||||
"article": "articles",
|
"article": "articles",
|
||||||
"note": "notes",
|
"note": "notes",
|
||||||
"annex": "annexes",
|
"annex": "annexes",
|
||||||
"author": "authors"
|
"author": "authors",
|
||||||
|
"editor": "editors"
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
{{ $_ := newScratch }}
|
{{ $_ := newScratch }}
|
||||||
{{ $debug := (slice) }}
|
{{ $debug := (slice) }}
|
||||||
|
|
||||||
|
{{ $sandnameSingular := (slice) }}
|
||||||
|
{{ $sandnamePlural := (slice) }}
|
||||||
|
|
||||||
|
{{ range $k, $v := $.Site.Data.sandpointsnamegraph }}
|
||||||
|
{{ $sandnameSingular = $sandnameSingular | append $k }}
|
||||||
|
{{ $sandnamePlural = $sandnamePlural | append $v }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ $pPath := "" }}
|
{{ $pPath := "" }}
|
||||||
{{ range $p := .Site.RegularPages }}
|
{{ range $p := .Site.RegularPages }}
|
||||||
{{ $pPath = printf "/%s" $p.File }}
|
{{ $pPath = printf "/%s" $p.File }}
|
||||||
|
@ -23,16 +31,22 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with $authors := $p.Params.authors }}
|
{{ $paramsKeys := (slice) }}
|
||||||
{{ range $author := $authors }}
|
{{ range $k, $v := $p.Params }}
|
||||||
{{ $authorLink := printf "/author/%s" $author }}
|
{{ $paramsKeys = $paramsKeys | append $k }}
|
||||||
{{ with ($_.Get $authorLink) }}
|
{{ end }}
|
||||||
{{ $_.SetInMap $authorLink "backlinks" (uniq ((index ($_.Get $authorLink) "backlinks") | append $p)) }}
|
|
||||||
|
{{ $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 }}
|
{{ else }}
|
||||||
{{ $_.SetInMap $authorLink "backlinks" (slice $p) }}
|
{{ $_.SetInMap $mentionLink "backlinks" (slice $p) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $gp := $.GetPage $pPath }}
|
{{ $gp := $.GetPage $pPath }}
|
||||||
{{ $gpPath := printf "/%s" $gp.File }}
|
{{ $gpPath := printf "/%s" $gp.File }}
|
||||||
|
|
Loading…
Add table
Reference in a new issue