{{- $site := .Site -}} {{- $siteURL := strings.TrimSuffix "/" $site.BaseURL -}} {{- $publisherID := printf "%s/#organization" $siteURL -}} {{- $authorID := printf "%s/#eddie-soehnel" $siteURL -}} {{- $licenseURL := "https://creativecommons.org/licenses/by/4.0/" -}} {{- $usageInfoURL := "https://indx.earth/wiki/license/" -}} {{- $artifactBase := "" -}} {{- $pageType := "" -}} {{- $canonicalURL := .Permalink -}} {{- $pageID := printf "%s#webpage" $canonicalURL -}} {{- if .IsHome -}} {{- $artifactBase = "/data/open/pages/home" -}} {{- $pageType = "WebPage" -}} {{- else if and .File (eq .Kind "page") (strings.HasPrefix .File.Path "community-summaries/") -}} {{- $slug := .Params.slug | default .File.BaseFileName -}} {{- $dir := strings.TrimSuffix "/" .File.Dir -}} {{- $artifactBase = printf "/data/open/pages/%s/%s" $dir $slug -}} {{- $pageType = "Article" -}} {{- $pageID = printf "%s#article" $canonicalURL -}} {{- else if and .File (eq .Kind "page") (ne .File.BaseFileName "healthz") -}} {{- $pageType = "WebPage" -}} {{- else if eq .Kind "section" -}} {{- $pageType = "CollectionPage" -}} {{- $pageID = printf "%s#collection" $canonicalURL -}} {{- end -}} {{- if $artifactBase -}} {{- $chunksURL := printf "%s/chunks.json" $artifactBase | absURL -}} {{- $qaURL := printf "%s/qa.json" $artifactBase | absURL -}} {{- end -}} {{- if $pageType -}} {{- $description := .Description | default .Summary | plainify -}} {{- $graph := slice -}} {{- $graph = $graph | append (dict "@type" "WebSite" "@id" (printf "%s/#website" $siteURL) "name" $site.Title "url" (printf "%s/" $siteURL) "publisher" (dict "@id" $publisherID) ) -}} {{- $graph = $graph | append (dict "@type" "Organization" "@id" $publisherID "name" "iNDX" "url" (printf "%s/" $siteURL) ) -}} {{- $graph = $graph | append (dict "@type" "Person" "@id" $authorID "name" (.Params.author | default "Eddie Soehnel") ) -}} {{- if eq $pageType "CollectionPage" -}} {{- $items := slice -}} {{- range .Pages.ByDate.Reverse -}} {{- $item := dict "@type" "Article" "url" .Permalink "headline" .Title -}} {{- with .Date -}} {{- $item = merge $item (dict "datePublished" (.Format "2006-01-02")) -}} {{- end -}} {{- $items = $items | append $item -}} {{- end -}} {{- $pageNode := dict "@type" "CollectionPage" "@id" $pageID "url" $canonicalURL "name" .Title "description" $description "isPartOf" (dict "@id" (printf "%s/#website" $siteURL)) "inLanguage" $site.LanguageCode "license" $licenseURL "usageInfo" $usageInfoURL "hasPart" $items -}} {{- $graph = $graph | append $pageNode -}} {{- else -}} {{- $pageNode := dict "@type" $pageType "@id" $pageID "url" $canonicalURL "name" .Title "headline" .Title "description" $description "isPartOf" (dict "@id" (printf "%s/#website" $siteURL)) "author" (dict "@id" $authorID) "publisher" (dict "@id" $publisherID) "inLanguage" $site.LanguageCode "license" $licenseURL "usageInfo" $usageInfoURL -}} {{- with .Date -}} {{- $pageNode = merge $pageNode (dict "datePublished" (.Format "2006-01-02") "dateModified" (.Format "2006-01-02") ) -}} {{- else -}} {{- with .Params.created_at -}} {{- $pageNode = merge $pageNode (dict "datePublished" . "dateModified" . ) -}} {{- end -}} {{- end -}} {{- with .Params.tags -}} {{- $pageNode = merge $pageNode (dict "keywords" .) -}} {{- end -}} {{- if $artifactBase -}} {{- $chunksID := printf "%s%s/chunks.json#dataset" $siteURL $artifactBase -}} {{- $qaID := printf "%s%s/qa.json#dataset" $siteURL $artifactBase -}} {{- $pageNode = merge $pageNode (dict "subjectOf" (slice (dict "@id" $chunksID) (dict "@id" $qaID))) -}} {{- $chunksNode := dict "@type" "Dataset" "@id" $chunksID "name" (printf "Semantic chunks for %s" .Title) "description" "Machine-readable semantic chunk artifact for this page." "creator" (dict "@id" $authorID) "isBasedOn" (dict "@id" $pageID) "encodingFormat" "application/json" "license" $licenseURL "usageInfo" $usageInfoURL "distribution" (dict "@type" "DataDownload" "encodingFormat" "application/json" "contentUrl" (printf "%s%s/chunks.json" $siteURL $artifactBase) ) -}} {{- $qaNode := dict "@type" "Dataset" "@id" $qaID "name" (printf "Semantic QA for %s" .Title) "description" "Machine-readable question-answer artifact for this page." "creator" (dict "@id" $authorID) "isBasedOn" (dict "@id" $pageID) "encodingFormat" "application/json" "license" $licenseURL "usageInfo" $usageInfoURL "distribution" (dict "@type" "DataDownload" "encodingFormat" "application/json" "contentUrl" (printf "%s%s/qa.json" $siteURL $artifactBase) ) -}} {{- $graph = $graph | append $pageNode -}} {{- $graph = $graph | append $chunksNode -}} {{- $graph = $graph | append $qaNode -}} {{- else -}} {{- $graph = $graph | append $pageNode -}} {{- end -}} {{- end -}} {{- $jsonLD := dict "@context" "https://schema.org" "@graph" $graph -}} {{- end -}}