Skip to content

Commit

Permalink
feat: add dataset structured data as JSON-LD to collection pages and …
Browse files Browse the repository at this point in the history
…denote hasPart/isPartOf relations
  • Loading branch information
rkettelerij committed Oct 1, 2024
1 parent 07a92cf commit e4397bb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
20 changes: 14 additions & 6 deletions internal/ogc/common/core/templates/landing-page.go.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@
"name": "{{ .Config.Title }} (OGC API)",
"description": "{{ unmarkdown .Config.Abstract }}",
"url": "{{ .Config.BaseURL }}?f=html",
{{- if .Config.Keywords -}}
{{- if .Config.Keywords }}
"keywords": ["{{ .Config.Keywords | join ", " }}"],
{{- end -}}
{{- end }}
"license": "{{ .Config.License.URL }}",
"isAccessibleForFree": true,
"version": "{{ .Config.Version }}",
{{- if .Config.Support -}}
{{- if .Config.Support }}
"creator":{
"@type":"Organization",
"name":"{{ .Config.Support.Name }}"
}
{{- end -}}
},
"hasPart": [
{{- range $index, $coll := .Config.AllCollections.Unique }}
{{- if $index }},{{ end }}
{
"@type": "URL",
"url": "{{ $.Config.BaseURL }}/collections/{{ $coll.ID }}"
}
{{- end }}
]
{{- end }}
}
</script>

Expand Down
26 changes: 26 additions & 0 deletions internal/ogc/common/geospatial/templates/collection.go.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@
}
</script>

{{/* structed data for this collection, see https://developers.google.com/search/docs/appearance/structured-data/dataset.
test any changes using https://search.google.com/test/rich-results */}}
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Dataset",
"isPartOf": "{{ .Config.BaseURL }}?f=html",
"name": "{{ .Config.Title }} - {{ if and .Params.Metadata .Params.Metadata.Title }}{{ .Params.Metadata.Title }}{{ else }}{{ .Params.ID }}{{ end }}",
{{- if and .Params.Metadata .Params.Metadata.Description (gt (len .Params.Metadata.Description) 50) }}
"description": "{{ unmarkdown .Params.Metadata.Description }}",
{{- end }}
"url": "{{ .Config.BaseURL }}/collections/{{ .Params.ID }}?f=html",
{{- if and .Params.Metadata .Params.Metadata.Keywords -}}
"keywords": ["{{ .Params.Metadata.Keywords | join ", " }}"],
{{- end -}}
"license": "{{ .Config.License.URL }}",
"isAccessibleForFree": true,
{{- if .Config.Support }}
"creator":{
"@type":"Organization",
"name":"{{ .Config.Support.Name }}"
}
{{- end }}
}
</script>

<hgroup>
<h1 class="title h2" id="title">{{ .Config.Title }} - {{ if and .Params.Metadata .Params.Metadata.Title }}{{ .Params.Metadata.Title }}{{ else }}{{ .Params.ID }}{{ end }}</h1>
</hgroup>
Expand Down

0 comments on commit e4397bb

Please sign in to comment.