{{- /* Set a variable to determine if we wrote a link */ -}} {{- .Scratch.Set "page_found" false -}} {{- if .Get "title" -}} {{- $page := .Get "title" -}} {{- $anchor_set := split $page "#" -}} {{- /* If they supplied a local, in-page, anchor. For example {{}} then there will be nothing at index 0 */ -}} {{- if (index $anchor_set 0) -}} {{- /* Match our version, our product and the given page title */ -}} {{- /* The use of "trim" handles links like {{}} */ -}} {{- range where (where (where .Site.Pages ".Page.Params.version" .Page.Params.version) ".Page.Params.product" .Page.Params.product) ".Page.Title" (trim (index $anchor_set 0) "/") -}} {{- /* This is the same function chain used to create the ToC, ensuring our anchor links render properly */ -}} {{- default .Page.Title ($.Get "text") -}} {{- $.Scratch.Set "page_found" true -}} {{- end -}} {{- else -}} {{- /* "If it's a local page anchor, generate a full link to the current page" */ -}} {{- default .Page.Title ($.Get "text") -}} {{- $.Scratch.Set "page_found" true -}} {{- end -}} {{- else if .Get "url" -}} {{- $page := (trim (.Get "url") "/") -}} {{- $anchor_set := split $page "#" -}} {{- /* If they supplied a local, in-page, anchor. For example {{}} then there will be nothing at index 0*/ -}} {{- if (index $anchor_set 0) -}} {{- range where (where .Site.Pages ".Page.Params.version" .Page.Params.version) ".Page.Params.product" .Page.Params.product -}} {{- /* I don't see a way to apply 'urlize' as a transformation to the where statement, so it's a stand alone if */ -}} {{- if eq (urlize .Page.Title) (trim (index $anchor_set 0) "/") -}} {{- default .Page.Title ($.Get "text") -}} {{- $.Scratch.Set "page_found" true -}} {{- end -}} {{- end -}} {{- else -}} {{- default .Page.Title ($.Get "text") -}} {{- $.Scratch.Set "page_found" true -}} {{- end -}} {{- end -}} {{ if not (.Scratch.Get "page_found") }} {{- if and (eq .Page.Params.product "Cumulus Linux") (eq .Page.Params.version "4.2") -}} {{- /* errorf "broken link in %s" .Position */ -}} {{- end -}} {{- if and (eq .Page.Params.product "Cumulus NetQ") (eq .Page.Params.version "3.2") -}} {{- /* errorf "broken link in %s" .Position */ -}} {{- end -}} UNABLE TO FIND LINK {{.Get 0}} {{- end -}}