From b290c57d3d016136e7227593184607a6cb3b4342 Mon Sep 17 00:00:00 2001 From: Henk Verlinde Date: Tue, 28 Sep 2021 16:26:15 +0200 Subject: [PATCH] feat: add versioning setup --- assets/js/index.js | 2 +- config/_default/config.toml | 1 + config/_default/menus/menus.en.toml | 3 +- config/_default/params.toml | 5 +- content/en/versions.md | 11 ++++ data/.gitkeep | 0 data/docs-versions.yml | 60 ++++++++++++++++++++++ layouts/_default/versions.html | 27 ++++++++++ layouts/index.headers | 5 +- layouts/index.html | 4 +- layouts/index.redirects | 11 +++- layouts/partials/footer/script-footer.html | 2 +- layouts/partials/head/stylesheet.html | 2 +- layouts/partials/header/header.html | 11 ++-- 14 files changed, 127 insertions(+), 17 deletions(-) create mode 100644 content/en/versions.md delete mode 100644 data/.gitkeep create mode 100644 data/docs-versions.yml create mode 100644 layouts/_default/versions.html diff --git a/assets/js/index.js b/assets/js/index.js index 9866d9d..c10a58b 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -102,7 +102,7 @@ Source: {{ range $index, $element := $list -}} { id: {{ $index }}, - href: "{{ .Permalink }}", + href: "{{ .RelPermalink }}", title: {{ .Title | jsonify }}, description: {{ .Params.description | jsonify }}, content: {{ .Content | jsonify }} diff --git a/config/_default/config.toml b/config/_default/config.toml index 1e87b85..17c3bc6 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -62,6 +62,7 @@ rel = "sitemap" [permalinks] blog = "/blog/:title/" + docs = "/docs/1.0/:sections[1:]/:title/" [minify.tdewolff.html] keepWhitespace = false diff --git a/config/_default/menus/menus.en.toml b/config/_default/menus/menus.en.toml index 9f57991..99e0e1c 100644 --- a/config/_default/menus/menus.en.toml +++ b/config/_default/menus/menus.en.toml @@ -12,7 +12,8 @@ [[main]] name = "Docs" - url = "/docs/prologue/introduction/" +# url = "/docs/prologue/introduction/" + url = "/docs/1.0/prologue/introduction/" weight = 10 [[main]] diff --git a/config/_default/params.toml b/config/_default/params.toml index 0774ebd..5de08c3 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -6,6 +6,9 @@ titleSeparator = "-" titleAddition = "Modern Documentation Theme" description = "Doks is a Hugo theme helping you build modern documentation websites that are secure, fast, and SEO-ready — by default." +## Documentation +docsVersion = "1.0" + ## Open Graph images = ["doks.png"] ogLocale = "en_US" @@ -79,4 +82,4 @@ editPage = false kaTex = false collapsibleSidebar = true multilingualMode = false - docsVersioning = false # Not yet functional + docsVersioning = true diff --git a/content/en/versions.md b/content/en/versions.md new file mode 100644 index 0000000..09eeb2d --- /dev/null +++ b/content/en/versions.md @@ -0,0 +1,11 @@ +--- +title: "Versions" +description: "" +lead: "An appendix of hosted documentation for nearly every release of Doks, from v0 through v3." +date: 2021-09-24T08:50:23+02:00 +lastmod: 2021-09-24T08:50:23+02:00 +draft: false +images: [] +layout: versions +url: "/docs/versions/" +--- diff --git a/data/.gitkeep b/data/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/data/docs-versions.yml b/data/docs-versions.yml new file mode 100644 index 0000000..8e7e5dd --- /dev/null +++ b/data/docs-versions.yml @@ -0,0 +1,60 @@ +# - group: v1.x +# baseurl: "https://getbootstrap.com" +# description: "Every minor and patch release from v1 is listed below." +# versions: +# - v: "1.0.0" +# - v: "1.1.0" +# - v: "1.1.1" +# - v: "1.2.0" +# - v: "1.3.0" +# - v: "1.4.0" +# +# - group: v2.x +# baseurl: "https://getbootstrap.com" +# description: "Every minor and patch release from v2 is listed below." +# versions: +# - v: "2.0.0" +# - v: "2.0.1" +# - v: "2.0.2" +# - v: "2.0.3" +# - v: "2.0.4" +# - v: "2.1.0" +# - v: "2.1.1" +# - v: "2.2.0" +# - v: "2.2.1" +# - v: "2.2.2" +# - v: "2.3.0" +# - v: "2.3.1" +# - v: "2.3.2" +# +# - group: v3.x +# baseurl: "https://getbootstrap.com/docs" +# description: "Every minor and patch release from v3 is listed below. Last update was v3.4.1." +# versions: +# - v: "3.3" +# - v: "3.4" +# +# - group: v4.x +# baseurl: "https://getbootstrap.com/docs" +# description: "Our previous major release with its minor releases. Last update was v4.6.0." +# versions: +# - v: "4.0" +# - v: "4.1" +# - v: "4.2" +# - v: "4.3" +# - v: "4.4" +# - v: "4.5" +# - v: "4.6" + +- group: v0.x + baseurl: "/docs" + description: "Current major release. Last update was v0.2.0." + versions: + - v: "0.1" + - v: "0.2" + +- group: v1.x + baseurl: "/docs" + description: "Every minor and patch release from v1 is listed below. Last update was v1.0.0." + versions: + - v: "1.0" diff --git a/layouts/_default/versions.html b/layouts/_default/versions.html new file mode 100644 index 0000000..3101b82 --- /dev/null +++ b/layouts/_default/versions.html @@ -0,0 +1,27 @@ +{{ define "main" }} +
+

{{ .Title }}

+

{{ .Params.lead | safeHTML }}

+ {{ .Content }} +
+ {{ range $release := sort (index $.Site.Data "docs-versions") "group" "desc" -}} +
+

{{ $release.group }}

+

{{ $release.description }}

+ {{ $versions := sort $release.versions "v" "desc" -}} + {{ range $i, $version := $versions -}} + {{ $len := len $versions -}} + {{ if (eq $i 0) }}{{ end }} + {{ end -}} +
+ {{ end -}} +
+
+{{ end }} diff --git a/layouts/index.headers b/layouts/index.headers index b41fdf3..8926db5 100644 --- a/layouts/index.headers +++ b/layouts/index.headers @@ -2,8 +2,9 @@ Strict-Transport-Security: max-age=31536000; includeSubDomains; preload X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block - Content-Security-Policy: default-src 'self'; frame-ancestors https://jamstackthemes.dev; manifest-src 'self'; connect-src 'self'; font-src 'self'; img-src 'self' data:; script-src 'self' 'sha512-RBYr6Ld4w1yVqaACrgrBLQfPgGhj/1jyacA74WxJ1KM6KVcSWymwrdDwb3HDcdpwiNJ5yssot1He0U9vXoQVlg=='; style-src 'self' 'unsafe-inline' + Content-Security-Policy: default-src 'self'; frame-ancestors https://jamstackthemes.dev; manifest-src 'self' https://*.netlify.app; connect-src 'self' https://*.netlify.app; font-src 'self' https://*.netlify.app; img-src 'self' https://*.netlify.app data:; script-src 'self' https://*.netlify.app 'sha512-RBYr6Ld4w1yVqaACrgrBLQfPgGhj/1jyacA74WxJ1KM6KVcSWymwrdDwb3HDcdpwiNJ5yssot1He0U9vXoQVlg=='; style-src 'self' https://*.netlify.app 'unsafe-inline' X-Frame-Options: SAMEORIGIN Referrer-Policy: strict-origin Feature-Policy: geolocation 'self' - Cache-Control: public, max-age=31536000 \ No newline at end of file + Cache-Control: public, max-age=31536000 + Access-Control-Allow-Origin: * \ No newline at end of file diff --git a/layouts/index.html b/layouts/index.html index 5496eda..034d8c0 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -6,8 +6,8 @@

{{ .Params.lead | safeHTML }}

- {{ i18n "get-started" }} -

Open-source MIT Licensed. GitHub v{{ $data := getJSON "https://raw.githubusercontent.com/h-enk/doks/master/package.json" }}{{ $data.version }}

+ Get Started +

Open-source MIT Licensed. GitHub v{{ $data := getJSON "/package.json" }}{{ $data.version }}

diff --git a/layouts/index.redirects b/layouts/index.redirects index 4323285..eee8102 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,6 +1,13 @@ -# redirects for Netlify - https://www.netlify.com/docs/redirects/ {{- range $p := .Site.Pages -}} {{- range .Aliases }} {{ . }} {{ $p.RelPermalink -}} {{- end }} -{{- end -}} \ No newline at end of file +{{- end -}} + +/docs/1.0/prologue/ /docs/1.0/prologue/introduction/ +/docs/1.0/help/ /docs/1.0/help/how-to-update/ +/docs/1.0/ /docs/1.0/prologue/introduction/ +/docs/ /docs/1.0/prologue/introduction/ + +/docs/0.1/* https://v0-1-0--doks-versioning-poc.netlify.app/docs/0.1/:splat 200 +/docs/0.2/* https://v0-2-0--doks-versioning-poc.netlify.app/docs/0.2/:splat 200 diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index 8d0ef26..159ad3f 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -100,6 +100,6 @@ {{ end -}} {{ if and (.Site.Params.options.flexSearch) (eq .Section "docs") -}} - + {{ end -}} {{ end -}} \ No newline at end of file diff --git a/layouts/partials/head/stylesheet.html b/layouts/partials/head/stylesheet.html index 2f5cab3..4dc25c0 100644 --- a/layouts/partials/head/stylesheet.html +++ b/layouts/partials/head/stylesheet.html @@ -6,6 +6,6 @@ {{ $options := (dict "targetPath" "main.css" "outputStyle" "compressed" "includePaths" (slice "node_modules")) -}} {{ $css := resources.Get "scss/app.scss" | toCSS $options | postCSS (dict "config" "config/postcss.config.js") -}} {{ $secureCSS := $css | resources.Fingerprint "sha512" -}} - + {{ end -}} \ No newline at end of file diff --git a/layouts/partials/header/header.html b/layouts/partials/header/header.html index 1f5d7b8..428bec1 100644 --- a/layouts/partials/header/header.html +++ b/layouts/partials/header/header.html @@ -107,14 +107,13 @@ {{ if eq .Site.Params.options.docsVersioning true -}}