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
|
@ -14,5 +14,6 @@
|
|||
"article": "articles",
|
||||
"note": "notes",
|
||||
"annex": "annexes",
|
||||
"author": "authors"
|
||||
"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,13 +31,19 @@
|
|||
{{ 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) }}
|
||||
{{ $_.SetInMap $mentionLink "backlinks" (slice $p) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in New Issue