diff --git a/_vendor/github.com/linode/linode-docs-theme/layouts/partials/sections/body-structured-data.html b/_vendor/github.com/linode/linode-docs-theme/layouts/partials/sections/body-structured-data.html index ca9fbd4d1de..59ffd7302fb 100644 --- a/_vendor/github.com/linode/linode-docs-theme/layouts/partials/sections/body-structured-data.html +++ b/_vendor/github.com/linode/linode-docs-theme/layouts/partials/sections/body-structured-data.html @@ -1,4 +1,4 @@ -{{ $schemaCommonParts := partialCached "sections/head-structured-data-parts" . }} +{{ $schemaCommonParts := partialCached "sections/body-structured-data-parts-common" . }} {{ $img := (partial "funcs/get-social-image.html" .).img }} {{ $p := .Params }} @@ -19,17 +19,30 @@ {{ end }} {{ $mainEntityOfPage := dict "@type" "WebPage" "@id" .Permalink }} - +{{ $ancestors := .Ancestors.Reverse }} +{{ $ancestorsSlice := slice }} +{{ range $ancestors }} + {{ if .IsHome }} + {{ continue }} + {{ end }} + {{ $ancestorsSlice = $ancestorsSlice | append .LinkTitle }} +{{ end }} {{ $schema := dict "@context" "https://schema.org" - "@type" "NewsArticle" + "@type" "TechArticle" "mainEntityOfPage" $mainEntityOfPage + "name" .LinkTitle "headline" .Title + "description" (or .Params.description .Summary) + "keywords" .Keywords "image" $img.Permalink "datePublished" .PublishDate "dateModified" .Lastmod "author" $author "publisher" $schemaCommonParts.publisher + "potentialAction" (dict "@type" "ReadAction" "target" (slice .Permalink)) + "articleSection" $ancestorsSlice + "hasPart" (partial "sections/body-structured-data-parts-haspart" .) }} {{ $script := printf `` "\n\t" ($schema | jsonify ) "\n" }} @@ -45,7 +58,7 @@ {{ end }} {{ end }} -{{ define "partials/sections/head-structured-data-parts" }} +{{ define "partials/sections/body-structured-data-parts-common" }} {{ $logo := "media/images/linode-logo-black.png" | absURL }} {{ $publisher := printf `{ "@type": "Organization", @@ -60,3 +73,120 @@ {{ $parts := dict "publisher" $publisher }} {{ return $parts }} {{ end }} + +{{ define "partials/sections/body-structured-data-parts-haspart" }} + {{/* First look for either schema_sections front matter or schema_sections.yml bundle resource. */}} + {{/* If not found, generate that structure from the hierarchy of the sections in the guide. */}} + {{ $parts := slice }} + {{ if or true (eq .Path "/guides/web-servers/nginx/using-nginx-proxy-manager") }} + {{ $schemaFromFrontMatter := .Params.schema_sections }} + {{ if not $schemaFromFrontMatter }} + {{ with .Resources.Get "schema_sections.yml" }} + {{ $schemaFromFrontMatter = . | transform.Unmarshal }} + {{ end }} + {{ end }} + {{ if $schemaFromFrontMatter }} + {{ $s := newScratch }} + {{ template "sections/body-structured-data-sections-frontmatter-recursive" (dict "headings" $schemaFromFrontMatter "s" $s "level" 0 ) }} + {{ $items := ($s.Get "itemListElement") }} + {{ $parts = $items }} + {{ else }} + {{ $s := newScratch }} + {{ template "sections/body-structured-data-sections-recursive" (dict "headings" .Fragments.Headings "s" $s ) }} + {{ $items := ($s.Get "itemListElement") }} + {{ if eq (len $items) 1 }} + {{ $first := index $items 0 }} + {{ if not $first.name }} + {{/* Remove empty root. */}} + {{ $items = index $first "itemListElement" | default slice }} + {{ end }} + {{ end }} + {{ $parts = $items }} + {{ end }} + {{ end }} + {{ return $parts }} +{{ end }} + +{{ define "sections/body-structured-data-sections-recursive" }} + {{ $headings := .headings }} + {{ $s1 := .s }} + {{ $s1.Set "itemListElement" slice }} + {{ range $i, $e := $headings }} + {{ $pos := add $i 1 }} + {{ $type := "HowToSection" }} + {{ $name := .Title }} + {{ $itemListElement := slice }} + {{ with .Headings }} + {{ $s2 := newScratch }} + {{ template "sections/body-structured-data-sections-recursive" (dict "headings" . "s" $s2 ) }} + {{ $itemListElement = $s2.Get "itemListElement" }} + {{ end }} + + {{ $item := "" }} + {{ if $itemListElement }} + {{ $item = dict + "@type" $type + "position" $pos + "name" $name + "itemListElement" $itemListElement + }} + {{ else }} + {{ $item = dict + "@type" $type + "position" $pos + "name" $name + }} + {{ end }} + {{ $s1.Add "itemListElement" $item }} + {{ end }} + +{{ end }} + +{{ define "sections/body-structured-data-sections-frontmatter-recursive" }} + {{ $headings := .headings }} + {{ $s1 := .s }} + {{ $level := .level }} + {{ $s1.Set "itemListElement" slice }} + {{ $isStep := true }} + {{ range $headings }} + {{ $items := (index . "items") }} + {{ if $items }} + {{/* Make branch nodes into sections. */}} + {{ $isStep = false }} + {{ break }} + {{ end }} + {{ end }} + {{ range $i, $e := $headings }} + {{ $pos := add $i 1 }} + {{ $items := (index $e "items") }} + {{ $type := "HowToSection" }} + {{ if $isStep }} + {{ $type = "HowToStep" }} + {{ end }} + {{ $name := .name }} + {{ $itemListElement := slice }} + {{ with $items }} + {{ $s2 := newScratch }} + {{ template "sections/body-structured-data-sections-frontmatter-recursive" (dict "headings" . "s" $s2 "level" (add $level 1) ) }} + {{ $itemListElement = $s2.Get "itemListElement" }} + {{ end }} + + {{ $item := "" }} + {{ if $itemListElement }} + {{ $item = dict + "@type" $type + "position" $pos + "name" $name + "itemListElement" $itemListElement + }} + {{ else }} + {{ $item = dict + "@type" $type + "position" $pos + "name" $name + }} + {{ end }} + {{ $s1.Add "itemListElement" $item }} + {{ end }} + +{{ end }} diff --git a/_vendor/modules.txt b/_vendor/modules.txt index 2e07ea559cd..549677e12c9 100644 --- a/_vendor/modules.txt +++ b/_vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/linode/linode-docs-theme v0.0.0-20250429183205-b5ce62d26795 +# github.com/linode/linode-docs-theme v0.0.0-20250513144910-cddeb56c075c # github.com/linode/linode-website-partials v0.0.0-20250409155719-a69a3433df0c # github.com/gohugoio/hugo-mod-jslibs-dist/alpinejs/v3 v3.21300.20800 # github.com/gohugoio/hugo-mod-jslibs/turbo/v8 v8.20000.20400 diff --git a/go.mod b/go.mod index 2ec99554bd6..79c57626a52 100644 --- a/go.mod +++ b/go.mod @@ -7,5 +7,5 @@ require ( github.com/gohugoio/hugo-mod-jslibs/turbo/v7 v7.20300.20000 // indirect github.com/instantpage/instant.page v5.1.1+incompatible // indirect github.com/linode/linode-api-docs/v4 v4.176.0 // indirect - github.com/linode/linode-docs-theme v0.0.0-20250429183205-b5ce62d26795 // indirect + github.com/linode/linode-docs-theme v0.0.0-20250513144910-cddeb56c075c // indirect ) diff --git a/go.sum b/go.sum index befd52adb44..efbd60f6e7b 100644 --- a/go.sum +++ b/go.sum @@ -322,6 +322,8 @@ github.com/linode/linode-docs-theme v0.0.0-20250414193030-a8fd512eed64 h1:vV+Tmb github.com/linode/linode-docs-theme v0.0.0-20250414193030-a8fd512eed64/go.mod h1:D4CREqxDmJW1ubkMagGdNUhKKE3h3ASWmnEUpqnJcsA= github.com/linode/linode-docs-theme v0.0.0-20250429183205-b5ce62d26795 h1:AOOYayvCmOuz5s3SSYXf+g/+x9qrhYbo8KY0daJNMR0= github.com/linode/linode-docs-theme v0.0.0-20250429183205-b5ce62d26795/go.mod h1:D4CREqxDmJW1ubkMagGdNUhKKE3h3ASWmnEUpqnJcsA= +github.com/linode/linode-docs-theme v0.0.0-20250513144910-cddeb56c075c h1:mGZmro7CoKOEPLrqzTDZBRmVTIPZk7ZlNX1q2H8f688= +github.com/linode/linode-docs-theme v0.0.0-20250513144910-cddeb56c075c/go.mod h1:D4CREqxDmJW1ubkMagGdNUhKKE3h3ASWmnEUpqnJcsA= github.com/linode/linode-website-partials v0.0.0-20221205205120-b6ea1aaa59fb/go.mod h1:K1Em3lwb16JiCwNVftAFwWGhyB9Zkl/nXhxjBBUC1Ao= github.com/linode/linode-website-partials v0.0.0-20221222200538-99862e429110/go.mod h1:K1Em3lwb16JiCwNVftAFwWGhyB9Zkl/nXhxjBBUC1Ao= github.com/linode/linode-website-partials v0.0.0-20230201145731-a8703d0a954a/go.mod h1:K1Em3lwb16JiCwNVftAFwWGhyB9Zkl/nXhxjBBUC1Ao=