Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@
{{- if and (ne $.Params.disable_opengraph_meta_tags true) .File -}}
{{- partial "meta.html" . -}}
{{- end -}}
{{- $mdURL := partialCached "page-agent-hint.html" (dict "ctx" .) .RelPermalink -}}
{{- with $mdURL -}}
<meta name="plaintext-source" content="{{ . }}">
{{- end -}}
</head>
{{- $bodyClass := $.Scratch.Get "bodyClass" -}}
{{- $customClass := $.Params.customclass -}}
{{ $ctx := . }}

<body
class="{{ .Site.Language.Lang }} {{ if .Kind }}kind-{{.Kind}}{{ end }} {{ if .IsPage }} {{ replace $.Type "/" "-" }} {{ else }} {{ .Section }} {{ end }} {{ $bodyClass }} {{ $customClass }} {{ if .Site.Params.announcement_banner }}announcement{{ end }}">
{{- with partialCached "page-agent-hint.html" (dict "ctx" .) .RelPermalink -}}
<div style="display:none" class="exclude-from-md">For a plaintext version of this page, see: {{ . }}</div>
{{- end -}}

<div class="greyside">
<div class="container container__content h-100">
Expand Down
14 changes: 14 additions & 0 deletions layouts/partials/page-agent-hint.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- $ctx := .ctx -}}
{{- $mdURL := "" -}}

{{- $rel := $ctx.RelPermalink -}}
{{- if and $rel (ne $rel "/") -}}
{{- $trimmed := strings.TrimRight "/" $rel | strings.TrimLeft "/" -}}
{{- $candidate := printf "https://docs.datadoghq.com/%s.md" $trimmed -}}
{{- $pages := partialCached "pages-json-cache.html" "pages.json" -}}
{{- if index $pages $candidate -}}
{{- $mdURL = $candidate -}}
{{- end -}}
{{- end -}}

{{- return $mdURL -}}
13 changes: 13 additions & 0 deletions layouts/partials/pages-json-cache.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- $url := "https://docs.datadoghq.com/pages.json" -}}

{{- $res := resources.GetRemote $url -}}
{{- with $res.Err -}}
{{- errorf "Failed to fetch remote JSON %s: %s" $url . -}}
{{- end -}}

{{- $pages := $res | transform.Unmarshal -}}
{{- if not $pages -}}
{{- errorf "Failed to unmarshal JSON from: %s" $url -}}
{{- end -}}

{{- return $pages -}}
Loading