diff --git a/.github/ISSUE_TEMPLATE/new_release.md b/.github/ISSUE_TEMPLATE/new_release.md index 396b24b5..8790fbb7 100644 --- a/.github/ISSUE_TEMPLATE/new_release.md +++ b/.github/ISSUE_TEMPLATE/new_release.md @@ -5,7 +5,7 @@ about: Cut a Crossplane release labels: release --- -- [ ] Update the `/latest` redirect in [netlify.toml](https://github.com/crossplane/docs/blob/master/netlify.toml#L9) +- [ ] Update the `$LATEST_VER` parameter in [netlify_build.sh](https://github.com/crossplane/docs/blob/master/netlify_build.sh#L3) - [ ] Update `params.latest` in [config.yaml](https://github.com/crossplane/docs/blob/master/config.yaml#L48) - [ ] Update `version` in the `_index.md` file of `/content/` - [ ] Create a [new release/tag](https://github.com/crossplane/docs/releases/new) named "v-archive" to snapshot EOL'd docs. diff --git a/netlify.toml b/netlify.toml index 68a4d5bf..3715b02f 100644 --- a/netlify.toml +++ b/netlify.toml @@ -4,21 +4,16 @@ command = "hugo --minify " -[[redirects]] -from = "/latest/*" -to = "/v1.12/:splat" -status = 302 - [[redirects]] from = "/docs/*" to = "/:splat" status = 302 [context.deploy-preview] - command = "sed -i 's/# writeStats: true/writeStats: true/g' config.yaml && cat config.yaml && hugo --minify" + command = "bash netlify_build.sh" [context.production] - command = "sed -i 's/# writeStats: true/writeStats: true/g' config.yaml && hugo --minify" + command = "bash netlify_build.sh" # Use [dev] to set configuration overrides for local # development environments run using Netlify Dev - except diff --git a/netlify_build.sh b/netlify_build.sh new file mode 100644 index 00000000..59010f0a --- /dev/null +++ b/netlify_build.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +LATEST_VER="1.12" + +cp -R content/v$LATEST_VER content/latest + +sed -i "s/^\s*version: \"$LATEST_VER\"//g" content/latest/_index.md + +sed -i 's/# writeStats: true/writeStats: true/g' config.yaml +cat config.yaml + +if [ $CONTEXT = "production"] +then +hugo --minify --baseURL $URL +else +hugo --minify --baseURL $DEPLOY_URL +fi \ No newline at end of file diff --git a/themes/geekboot/layouts/_default/sitemap.xml b/themes/geekboot/layouts/_default/sitemap.xml new file mode 100644 index 00000000..3ead1946 --- /dev/null +++ b/themes/geekboot/layouts/_default/sitemap.xml @@ -0,0 +1,17 @@ +{{ printf "" | safeHTML }} + + {{ range where .Site.Pages "Section" "latest" }} + + {{ .Permalink }}{{ if not .Lastmod.IsZero }} + {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }} + + {{ end }} + {{/* For KB and Contrib guides */}} + {{ range where .Site.Pages "Params.version" "0" }} + + {{ .Permalink }}{{ if not .Lastmod.IsZero }} + {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }} + + {{ end }} + \ No newline at end of file diff --git a/themes/geekboot/layouts/partials/header.html b/themes/geekboot/layouts/partials/header.html index f04c2c4f..4c505efc 100644 --- a/themes/geekboot/layouts/partials/header.html +++ b/themes/geekboot/layouts/partials/header.html @@ -15,9 +15,41 @@ {{ end }} {{ end }} +{{ $ver := .Page.Params.version | default .Site.Params.latest }} + - {{- if .IsHome -}}{{- .Site.Title | markdownify }} · {{.Site.Params.subtitle | markdownify }} {{- else }}{{- .Title | markdownify}} · {{ .Site.Title | markdownify }} {{ if and (ne .Page.Params.version "0") (ne .Page.Params.version "master")}}v{{.Page.Params.version }}{{end}}{{if eq .Page.Params.version "master"}}{{.Page.Params.version }}{{end}}{{ end }} - + {{- if .IsHome -}}{{- .Site.Title | markdownify }} · {{.Site.Params.subtitle | markdownify }} {{- else }}{{- .Title | markdownify}} · {{ .Site.Title | markdownify }} {{ if and (ne .Page.Params.version "0") (ne .Page.Params.version "master")}}v{{ $ver }}{{end}}{{if eq .Page.Params.version "master"}}{{.Page.Params.version }}{{end}}{{ end }} + + +{{/* Don't do the URL processing for KB and Contrib guides */}} +{{ if not .Page.Params.Product }} + {{/* Strip out the version from the path to get just the section + page */}} + {{ $sectionPage := replaceRE (printf "v%s/" .Page.Params.version) "" .RelPermalink }} + + {{/* Handle the /latest directory */}} + {{ if not .Page.Params.version }} + {{ $sectionPage = replaceRE "/latest" "" .RelPermalink }} + {{ end }} + + {{/* Handle the /master directory */}} + {{ if eq .Page.Params.version "master" }} + {{ $sectionPage = replaceRE "/master" "" .RelPermalink }} + {{ end }} + + {{/* Strip training / so .GetPage works */}} + {{ $sectionPage = strings.TrimRight "/" $sectionPage }} + + {{/* Look for the Page matching this page, but in the latest directory */}} + {{ $latestPage := .Site.GetPage (printf "/latest%s" $sectionPage) }} + + {{/* If it exists set the canonical URL to the latest, otherwise we are canonical */}} + {{ if $latestPage }} + + {{ end }} + +{{ else }} + +{{ end }} {{ partialCached "stylesheet-cached" . }} {{ partial "stylesheet-dynamic" . }} diff --git a/themes/geekboot/layouts/partials/single-list.html b/themes/geekboot/layouts/partials/single-list.html index 8d634d2c..ce7b3122 100644 --- a/themes/geekboot/layouts/partials/single-list.html +++ b/themes/geekboot/layouts/partials/single-list.html @@ -63,9 +63,11 @@
{{ if $.Param "docs" }} + {{ $pageVer := .Page.Params.version | default .Site.Params.latest }} + {{- if eq .Page.Params.version "master" -}} {{ partialCached "master-version-alert" . }} - {{- else if ne .Page.Params.version .Site.Params.latest -}} + {{- else if ne $pageVer .Site.Params.latest -}} {{ partialCached "old-version-alert" . .Section }} {{ end }} {{ end }} diff --git a/themes/geekboot/layouts/partials/version-dropdown-menu.html b/themes/geekboot/layouts/partials/version-dropdown-menu.html index 01fcdfcc..1e532368 100644 --- a/themes/geekboot/layouts/partials/version-dropdown-menu.html +++ b/themes/geekboot/layouts/partials/version-dropdown-menu.html @@ -2,7 +2,7 @@ {{ $majordict := dict }} {{ $majorlist := slice }} {{ $sorted_list := slice }} -{{ $cur_ver := .Page.Params.version }} +{{ $cur_ver := .Page.Params.version | default .Site.Params.latest }} {{ range .Site.Sections }} @@ -28,34 +28,42 @@