Skip to content

Commit

Permalink
add JSON page lists for use in the v3 UI (influxdata#5363)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderson authored Mar 14, 2024
1 parent 7520bcc commit 259e8e6
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 16 deletions.
9 changes: 9 additions & 0 deletions content/influxdb/cloud-dedicated/pages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: page-list
outputs: [json]
omit_from_sitemap: true
---

This file is used to generate a JSON file containing the navigation structure
for this product. The InfluxDB v3 UI retrieves this JSON to build documentation
links in the UI.
9 changes: 9 additions & 0 deletions content/influxdb/cloud-serverless/pages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: page-list
outputs: [json]
omit_from_sitemap: true
---

This file is used to generate a JSON file containing the navigation structure
for this product. The InfluxDB v3 UI retrieves this JSON to build documentation
links in the UI.
9 changes: 9 additions & 0 deletions content/influxdb/clustered/pages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: page-list
outputs: [json]
omit_from_sitemap: true
---

This file is used to generate a JSON file containing the navigation structure
for this product. The InfluxDB v3 UI retrieves this JSON to build documentation
links in the UI.
5 changes: 5 additions & 0 deletions hugo.staging.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ smartDashes = false
[privacy.youtube]
disable = false
privacyEnhanced = true

[outputFormats.json]
mediaType = "application/json"
baseName = "pages"
isPlainText = true
5 changes: 5 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ smartDashes = false
[privacy.youtube]
disable = false
privacyEnhanced = true

[outputFormats.json]
mediaType = "application/json"
baseName = "pages"
isPlainText = true
81 changes: 81 additions & 0 deletions layouts/_default/page-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{{- $productPathData := findRE "[^/]+.*?" .RelPermalink -}}
{{- $product := index $productPathData 0 -}}
{{- $version := index $productPathData 1 -}}
{{- $menuKey := print $product "_" (replaceRE `-` "_" $version) -}}
{{- $menu := index .Site.Menus $menuKey -}}
[
{{ range $index, $entry := $menu }}
{{- if $index -}},{{- end }}
{
"name": {{ .Name | jsonify }},
"url": {{ absURL (cond (isset .Params "url") .Params.url .URL) | jsonify }},
"children": [
{{- range $index, $entry := .Children -}}
{{- if $index -}},{{- end }}
{
"name": {{ .Name | jsonify }},
"url": {{ absURL (cond (isset .Params "url") .Params.url .URL) | jsonify }},
"children": [
{{- range $index, $entry := .Children -}}
{{- if $index -}},{{- end }}
{
"name": {{ .Name | jsonify }},
"url": {{ absURL (cond (isset .Params "url") .Params.url .URL) | jsonify }},
"children": [
{{- range $index, $entry := .Children -}}
{{- if $index -}},{{- end }}
{
"name": {{ .Name | jsonify }},
"url": {{ absURL (cond (isset .Params "url") .Params.url .URL) | jsonify }},
"children": [
{{- range $index, $entry := .Children -}}
{{- if $index -}},{{- end }}
{
"name": {{ .Name | jsonify }},
"url": {{ absURL (cond (isset .Params "url") .Params.url .URL) | jsonify }},
"children": [
{{- range $index, $entry := .Children -}}
{{- if $index -}},{{- end }}
{
"name": {{ .Name | jsonify }},
"url": {{ absURL (cond (isset .Params "url") .Params.url .URL) | jsonify }},
"children": [
{{- range $index, $entry := .Children -}}
{{- if $index -}},{{- end }}
{
"name": {{ .Name | jsonify }},
"url": {{ absURL (cond (isset .Params "url") .Params.url .URL) | jsonify }},
"children": [
{{- range $index, $entry := .Children -}}
{{- if $index -}},{{- end }}
{
"name": {{ .Name | jsonify }},
"url": {{ absURL (cond (isset .Params "url") .Params.url .URL) | jsonify }},
"children": [
{{ range .Children }}
{{ end }}
]
}
{{ end }}
]
}
{{ end }}
]
}
{{ end }}
]
}
{{ end }}
]
}
{{ end }}
]
}
{{ end }}
]
}
{{ end }}
]
}
{{ end }}
]
34 changes: 18 additions & 16 deletions layouts/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range .Data.Pages }}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
</url>
{{ if not .Params.omit_from_sitemap }}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
</url>
{{ end }}
{{ end }}
</urlset>

0 comments on commit 259e8e6

Please sign in to comment.