diff options
author | Henk Verlinde <henk@henkverlinde.com> | 2021-10-04 17:36:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-04 17:36:50 +0300 |
commit | 514844b40beee6b0f43a0ce0342ae9849dd16315 (patch) | |
tree | aa0b20ae6e1c216fcaa7349f2bc7234c33b00ed0 | |
parent | 94bacd3492e7b4d1e46aef13f86e5924ac645f4e (diff) | |
parent | 0b9c219922105bbf06d96bd3d63297e1ace9d404 (diff) |
Merge pull request #478 from h-enk/versioning
feat: add versioning setup
-rw-r--r-- | assets/js/index.js | 2 | ||||
-rw-r--r-- | config/_default/config.toml | 1 | ||||
-rw-r--r-- | config/_default/menus/menus.en.toml | 1 | ||||
-rw-r--r-- | config/_default/params.toml | 5 | ||||
-rw-r--r-- | content/en/versions.md | 11 | ||||
-rw-r--r-- | data/.gitkeep | 0 | ||||
-rw-r--r-- | data/docs-versions.yml | 60 | ||||
-rw-r--r-- | layouts/_default/versions.html | 27 | ||||
-rw-r--r-- | layouts/index.headers | 5 | ||||
-rw-r--r-- | layouts/index.html | 4 | ||||
-rw-r--r-- | layouts/index.redirects | 11 | ||||
-rw-r--r-- | layouts/partials/footer/script-footer.html | 2 | ||||
-rw-r--r-- | layouts/partials/head/stylesheet.html | 2 | ||||
-rw-r--r-- | layouts/partials/header/header.html | 11 |
14 files changed, 126 insertions, 16 deletions
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..df71fa9 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..935d480 100644 --- a/config/_default/menus/menus.en.toml +++ b/config/_default/menus/menus.en.toml @@ -13,6 +13,7 @@ [[main]] name = "Docs" 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..42cc484 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 = false diff --git a/content/en/versions.md b/content/en/versions.md new file mode 100644 index 0000000..ddbe002 --- /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: true +images: [] +layout: versions +url: "/docs/versions/" +--- diff --git a/data/.gitkeep b/data/.gitkeep deleted file mode 100644 index e69de29..0000000 --- a/data/.gitkeep +++ /dev/null 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" }} + <article> + <h1>{{ .Title }}</h1> + <p class="lead">{{ .Params.lead | safeHTML }}</p> + {{ .Content }} + <div class="row"> + {{ range $release := sort (index $.Site.Data "docs-versions") "group" "desc" -}} + <div class="col-md-8 col-lg-4 col-xl mb-4"> + <h2>{{ $release.group }}</h2> + <p>{{ $release.description }}</p> + {{ $versions := sort $release.versions "v" "desc" -}} + {{ range $i, $version := $versions -}} + {{ $len := len $versions -}} + {{ if (eq $i 0) }}<div class="list-group">{{ end }} + <a class="list-group-item list-group-item-action py-2 text-primary{{ if (eq $version.v $.Site.Params.docsVersion) }} d-flex justify-content-between align-items-center{{ end }}" href="{{ $release.baseurl }}/{{ $version.v }}/"> + {{ $version.v }} + {{ if (eq $version.v $.Site.Params.docsVersion) -}} + <span class="badge bg-primary">Latest</span> + {{ end -}} + </a> + {{ if (eq (add $i 1) $len) }}</div>{{ end }} + {{ end -}} + </div> + {{ end -}} + </div> + </article> +{{ 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 @@ </div> <div class="col-lg-9 col-xl-8 text-center"> <p class="lead">{{ .Params.lead | safeHTML }}</p> - <a class="btn btn-primary btn-lg px-4 mb-2" href="{{ "docs/prologue/introduction/" | relLangURL }}" role="button">{{ i18n "get-started" }}</a> - <p class="meta">Open-source MIT Licensed. <a href="https://github.com/h-enk/doks">GitHub v{{ $data := getJSON "https://raw.githubusercontent.com/h-enk/doks/master/package.json" }}{{ $data.version }}</a></p> + <a class="btn btn-primary btn-lg px-4 mb-2" href="/docs/{{ if .Site.Params.options.docsVersioning }}{{ .Site.Params.docsVersion }}/{{ end }}prologue/introduction/" role="button">Get Started</a> + <p class="meta">Open-source MIT Licensed. <a href="https://github.com/h-enk/doks-versioning-poc">GitHub v{{ $data := getJSON "/package.json" }}{{ $data.version }}</a></p> </div> </div> </section> diff --git a/layouts/index.redirects b/layouts/index.redirects index 4323285..5d7d6d2 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 @@ <script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script> {{ end -}} {{ if and (.Site.Params.options.flexSearch) (eq .Section "docs") -}} - <script src="{{ $index.RelPermalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script> + <script src="{{ $index.Permalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script> {{ 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" -}} - <link rel="stylesheet" href="{{ $secureCSS.Permalink | relURL }}" integrity="{{ $secureCSS.Data.Integrity }}" crossorigin="anonymous"> + <link rel="stylesheet" href="{{ $secureCSS.Permalink }}" integrity="{{ $secureCSS.Data.Integrity }}" crossorigin="anonymous"> {{ end -}} <noscript><style>img.lazyload { display: none; }</style></noscript>
\ 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 -}} <div class="dropdown ms-3"> <button class="btn btn-doks-light dropdown-toggle" id="doks-versions" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static" aria-label="Toggle version menu"> - <span class="d-none d-lg-inline">Doks</span> v5.0 + <span class="d-none d-lg-inline">Doks</span> v{{ .Site.Params.docsVersion }} </button> - <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="doks-versions"> - <li><a class="dropdown-item current" aria-current="true" href="/docs/5.0/">Latest (5.0.x)</a></li> + <ul class="dropdown-menu dropdown-menu-end shadow rounded border-0" aria-labelledby="doks-versions"> + <li><a class="dropdown-item current" aria-current="true" href="/docs/{{ .Site.Params.docsVersion }}/prologue/introduction/">Latest ({{ .Site.Params.docsVersion }}.x)</a></li> <li><hr class="dropdown-divider"></li> - <li><a class="dropdown-item" href="https://getbootstrap.com/docs/4.6/">v4.6.x</a></li> - <li><a class="dropdown-item" href="https://getbootstrap.com/docs/3.4/">v3.4.1</a></li> - <li><a class="dropdown-item" href="https://getbootstrap.com/2.3.2/">v2.3.2</a></li> + <li><a class="dropdown-item" href="/docs/0.2/prologue/introduction/">v0.2.x</a></li> + <li><a class="dropdown-item" href="/docs/0.1/prologue/introduction/">v0.1.x</a></li> <li><hr class="dropdown-divider"></li> <li><a class="dropdown-item" href="/docs/versions/">All versions</a></li> </ul> |