From 10d0b45203003a43727521dc9f5c35e655500309 Mon Sep 17 00:00:00 2001 From: Henk Verlinde Date: Fri, 2 Apr 2021 19:45:05 +0200 Subject: [PATCH] feat: update for netlify dev support --- assets/js/index.js | 2 +- config/_default/config.toml | 3 ++- config/next/config.toml | 2 ++ config/production/config.toml | 3 ++- config/staging/.gitkeep | 0 content/docs/prologue/introduction.md | 4 ++-- content/docs/prologue/quick-start.md | 2 +- content/privacy-policy/index.md | 2 +- layouts/_default/index.js | 2 +- layouts/_default/index.json | 2 +- layouts/_default/list.html | 2 +- layouts/_default/section.sitemap.xml | 12 +++++------ layouts/blog/list.html | 4 ++-- layouts/contributors/list.html | 4 ++-- layouts/docs/list.html | 4 ++-- layouts/index.html | 2 +- layouts/index.redirects | 2 +- layouts/partials/footer/footer.html | 2 +- layouts/partials/footer/script-footer.html | 24 +++++++++++----------- layouts/partials/head/favicons.html | 8 ++++---- layouts/partials/head/opengraph.html | 18 ++++++++-------- layouts/partials/head/resource-hints.html | 8 ++++---- layouts/partials/head/seo.html | 10 ++++----- layouts/partials/head/structured-data.html | 18 ++++++++-------- layouts/partials/head/stylesheet.html | 4 ++-- layouts/partials/head/twitter_cards.html | 6 +++--- layouts/partials/header/header.html | 6 +++--- layouts/partials/main/blog-meta.html | 2 +- layouts/partials/main/breadcrumb.html | 2 +- layouts/partials/main/docs-navigation.html | 4 ++-- layouts/partials/sidebar/docs-menu.html | 2 +- layouts/rss.xml | 8 ++++---- layouts/shortcodes/img-simple.html | 2 +- layouts/shortcodes/img.html | 6 +++--- layouts/sitemap.xml | 6 +++--- netlify.toml | 24 ++++++++++++++-------- package.json | 2 +- 37 files changed, 112 insertions(+), 102 deletions(-) create mode 100644 config/next/config.toml delete mode 100644 config/staging/.gitkeep diff --git a/assets/js/index.js b/assets/js/index.js index 28808a8..8c87d5f 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -86,7 +86,7 @@ Source: {{ range $index, $page := (where .Site.Pages "Section" "docs") -}} { id: {{ $index }}, - href: "{{ .Permalink | absURL }}", + href: "{{ .RelPermalink | relURL }}", title: {{ .Title | jsonify }}, description: {{ .Params.description | jsonify }}, content: {{ .Content | jsonify }} diff --git a/config/_default/config.toml b/config/_default/config.toml index 3277bb0..c800d6f 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -1,4 +1,5 @@ baseurl = "/" +canonifyURLs = false disableAliases = true disableHugoGeneratorInject = true enableEmoji = true @@ -72,7 +73,7 @@ rel = "sitemap" [taxonomies] contributor = "contributors" -[permalinks] +[RelPermalinks] blog = "/blog/:title/" [module] diff --git a/config/next/config.toml b/config/next/config.toml new file mode 100644 index 0000000..bf4bbcd --- /dev/null +++ b/config/next/config.toml @@ -0,0 +1,2 @@ +baseurl = "https://doks-next.netlify.app/" +canonifyURLs = true diff --git a/config/production/config.toml b/config/production/config.toml index 58155ea..c4ca660 100644 --- a/config/production/config.toml +++ b/config/production/config.toml @@ -1 +1,2 @@ -baseurl = "/" +baseurl = "https://doks.netlify.app/" +canonifyURLs = true diff --git a/config/staging/.gitkeep b/config/staging/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/content/docs/prologue/introduction.md b/content/docs/prologue/introduction.md index 1766779..64483e4 100644 --- a/content/docs/prologue/introduction.md +++ b/content/docs/prologue/introduction.md @@ -27,7 +27,7 @@ Step-by-step instructions on how to start a new Doks project. [Tutorial →](htt {{< alert icon="👉" text="The Quick Start is intended for intermediate to advanced users." >}} -One page summary of how to start a new Doks project. [Quick Start →]({{< ref "quick-start" >}}) +One page summary of how to start a new Doks project. [Quick Start →]({{< relref "quick-start" >}}) ## Go further @@ -55,4 +55,4 @@ Find out how to contribute to Doks. [Contributing →](https://getdoks.org/docs/ ## Help -Get help on Doks. [Help →]({{< ref "how-to-update" >}}) +Get help on Doks. [Help →]({{< relref "how-to-update" >}}) diff --git a/content/docs/prologue/quick-start.md b/content/docs/prologue/quick-start.md index a516f2a..6b6c25c 100644 --- a/content/docs/prologue/quick-start.md +++ b/content/docs/prologue/quick-start.md @@ -57,4 +57,4 @@ Doks will start the Hugo development webserver accessible by default at `http:// ## Other commands -Doks comes with commands for common tasks. [Commands →]({{< ref "commands" >}}) +Doks comes with commands for common tasks. [Commands →]({{< relref "commands" >}}) diff --git a/content/privacy-policy/index.md b/content/privacy-policy/index.md index e95fd9f..6315024 100644 --- a/content/privacy-policy/index.md +++ b/content/privacy-policy/index.md @@ -31,6 +31,6 @@ We run [Plausible](https://plausible.io/) analytics on getdoks.org. The followin ## Contact us -[Contact us]({{< ref "contact/index.md" >}}) if you have any questions. +[Contact us]({{< relref "contact/index.md" >}}) if you have any questions. Effective Date: _27th August 2020_ diff --git a/layouts/_default/index.js b/layouts/_default/index.js index 2dd84f7..9f764f9 100644 --- a/layouts/_default/index.js +++ b/layouts/_default/index.js @@ -4,7 +4,7 @@ var docs = [ id: {{ $index }}, title: "{{ .Title }}", description: "{{ .Params.description }}", - href: "{{ .URL | absURL }}" + href: "{{ .URL | relURL }}" }, {{ end -}} ]; \ No newline at end of file diff --git a/layouts/_default/index.json b/layouts/_default/index.json index b1997c8..6842871 100644 --- a/layouts/_default/index.json +++ b/layouts/_default/index.json @@ -1,5 +1,5 @@ {{- $.Scratch.Add "index" slice -}} {{- range .Site.RegularPages -}} - {{- $.Scratch.Add "index" (dict "title" .Title "description" .Params.description "contents" .Plain "permalink" .Permalink) -}} + {{- $.Scratch.Add "index" (dict "title" .Title "description" .Params.description "contents" .Plain "RelPermalink" .RelPermalink) -}} {{- end -}} {{- $.Scratch.Get "index" | jsonify -}} \ No newline at end of file diff --git a/layouts/_default/list.html b/layouts/_default/list.html index b746aa9..1401ccd 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -3,7 +3,7 @@
{{ range .Paginator.Pages }} {{ end }} diff --git a/layouts/_default/section.sitemap.xml b/layouts/_default/section.sitemap.xml index 701951d..9d047b4 100644 --- a/layouts/_default/section.sitemap.xml +++ b/layouts/_default/section.sitemap.xml @@ -4,19 +4,19 @@ {{ range $i, $e := .Data.Pages -}} {{ if ne .Params.sitemap_exclude true }} - {{ .Permalink }}{{ if not .Lastmod.IsZero }} + {{ .RelPermalink }}{{ if not .Lastmod.IsZero }} {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ with .Sitemap.ChangeFreq }} {{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }} {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }} {{ end }} {{ end }} {{ end -}} @@ -25,19 +25,19 @@ {{ range $i, $e := .Data.Pages -}} {{ if ne .Params.sitemap_exclude true -}} - {{ .Permalink }}{{ if not .Lastmod.IsZero }} + {{ .RelPermalink }}{{ if not .Lastmod.IsZero }} {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ with .Sitemap.ChangeFreq }} {{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }} {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }} {{ end }} {{ end }} {{ end -}} diff --git a/layouts/blog/list.html b/layouts/blog/list.html index b5fe8ca..a268ca5 100644 --- a/layouts/blog/list.html +++ b/layouts/blog/list.html @@ -5,10 +5,10 @@

{{ .Title }}

{{ .Content }}
- {{ range .Data.Pages -}} + {{ range .Data.Pages -}}
-

{{ .Params.title }}

+

{{ .Params.title }}

{{ .Params.lead | safeHTML }}

{{ partial "main/blog-meta.html" . -}}
diff --git a/layouts/contributors/list.html b/layouts/contributors/list.html index 45e07e6..adc53aa 100644 --- a/layouts/contributors/list.html +++ b/layouts/contributors/list.html @@ -4,11 +4,11 @@

{{ .Title }}

{{ .Content }}
-
+
{{ range .Data.Pages -}}
-

{{ .Params.title }}

+

{{ .Params.title }}

{{ if eq .Section "blog" -}}

{{ .Params.lead | safeHTML }}

{{ partial "main/blog-meta.html" . -}} diff --git a/layouts/docs/list.html b/layouts/docs/list.html index 9bc9b30..c860531 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -7,10 +7,10 @@
{{ $currentSection := .CurrentSection }} {{ range where .Site.RegularPages.ByTitle "Section" .Section }} - {{ if in (.Permalink | string) $currentSection.RelPermalink }} + {{ if in (.RelPermalink | string) $currentSection.RelPermalink }} {{ end }} diff --git a/layouts/index.html b/layouts/index.html index c2e142c..0205c33 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -6,7 +6,7 @@

{{ .Params.lead | safeHTML }}

- Get started + Get started

Open-source MIT Licensed. GitHub v{{ .Site.Data.doks.version }}

diff --git a/layouts/index.redirects b/layouts/index.redirects index 4323285..59a844c 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,6 +1,6 @@ # redirects for Netlify - https://www.netlify.com/docs/redirects/ {{- range $p := .Site.Pages -}} {{- range .Aliases }} -{{ . }} {{ $p.RelPermalink -}} +{{ . }} {{ $p.RelRelPermalink -}} {{- end }} {{- end -}} \ No newline at end of file diff --git a/layouts/partials/footer/footer.html b/layouts/partials/footer/footer.html index f2b4aca..bdd7450 100644 --- a/layouts/partials/footer/footer.html +++ b/layouts/partials/footer/footer.html @@ -9,7 +9,7 @@
diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index 8051dcb..c7b893b 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -53,18 +53,18 @@ {{ if eq (hugo.Environment) "development" -}} {{ if .Site.Params.options.bootStrapJs -}} - + {{ end -}} {{ if .Site.Params.options.highLight -}} - + {{ end -}} {{ if .Site.Params.options.kaTex -}} - - + + {{ end -}} - + {{ if .Site.Params.options.flexSearch -}} - + {{ end -}} {{ else -}} {{ $js := $js | minify | fingerprint "sha512" -}} @@ -74,17 +74,17 @@ {{ $katex := $katex | minify | fingerprint "sha512" -}} {{ $katexAutoRender := $katexAutoRender | minify | fingerprint "sha512" -}} {{ if .Site.Params.options.bootStrapJs -}} - + {{ end -}} {{ if .Site.Params.options.highLight -}} - + {{ end -}} {{ if .Site.Params.options.kaTex -}} - - + + {{ end -}} - + {{ if .Site.Params.options.flexSearch -}} - + {{ end -}} {{ end -}} \ No newline at end of file diff --git a/layouts/partials/head/favicons.html b/layouts/partials/head/favicons.html index 3988156..e34e521 100644 --- a/layouts/partials/head/favicons.html +++ b/layouts/partials/head/favicons.html @@ -1,5 +1,5 @@ - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/layouts/partials/head/opengraph.html b/layouts/partials/head/opengraph.html index 8080840..e375302 100644 --- a/layouts/partials/head/opengraph.html +++ b/layouts/partials/head/opengraph.html @@ -3,14 +3,14 @@ {{ if $.Scratch.Get "paginator" -}} {{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "blog" ) -}} - + {{ else -}} - + {{ end -}} {{ with $.Params.images -}} {{ range first 6 . -}} - + {{ end -}} {{ else -}} {{ $images := $.Resources.ByType "image" -}} @@ -19,10 +19,10 @@ {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} {{ end -}} {{ with $featured -}} - + {{ else -}} {{ with $.Site.Params.images -}} - + {{ end -}} {{ end -}} {{ end -}} @@ -54,18 +54,18 @@ {{ end -}} {{ with .Params.videos -}} {{ range . -}} - + {{ end -}} {{ end -}} -{{ $permalink := .Permalink -}} +{{ $RelPermalink := .RelPermalink -}} {{ $siteSeries := .Site.Taxonomies.series -}} {{ with .Params.series -}} {{ range $name := . -}} {{ $series := index $siteSeries $name -}} {{ range $page := first 6 $series.Pages -}} - {{ if ne $page.Permalink $permalink -}} - + {{ if ne $page.RelPermalink $RelPermalink -}} + {{ end -}} {{ end -}} {{ end -}} diff --git a/layouts/partials/head/resource-hints.html b/layouts/partials/head/resource-hints.html index 3baa711..754936d 100644 --- a/layouts/partials/head/resource-hints.html +++ b/layouts/partials/head/resource-hints.html @@ -1,6 +1,6 @@ - - + + {{ if .Site.Params.options.kaTex -}} - - + + {{ end -}} \ No newline at end of file diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html index 10a13fe..fe21bb1 100644 --- a/layouts/partials/head/seo.html +++ b/layouts/partials/head/seo.html @@ -23,15 +23,15 @@ {{ end -}} {{ if $.Scratch.Get "paginator" }} - + {{ if .Paginator.HasPrev -}} - + {{ end -}} {{ if .Paginator.HasNext -}} - + {{ end -}} {{ else -}} - + {{ end -}} {{ partial "head/twitter_cards.html" . }} @@ -44,7 +44,7 @@ {{ range .AlternativeOutputFormats -}} - + {{ end -}} {{ partial "head/structured-data.html" . }} diff --git a/layouts/partials/head/structured-data.html b/layouts/partials/head/structured-data.html index d54b24f..2f38fae 100644 --- a/layouts/partials/head/structured-data.html +++ b/layouts/partials/head/structured-data.html @@ -4,9 +4,9 @@ { "@context": "https://schema.org", "@type": "Organization", - "url": "{{ "/" | absURL }}", + "url": "{{ "/" | relURL }}", "name": "{{ .Site.Params.title }}", - "logo": "{{ "/" | absURL }}{{ .Site.Params.schemaLogo }}", + "logo": "{{ "/" | relURL }}{{ .Site.Params.schemaLogo }}", "sameAs": [ "{{ .Site.Params.schemaTwitter | safeURL }}", "{{ .Site.Params.schemaLinkedIn | safeURL }}", @@ -20,7 +20,7 @@ { "@context": "https://schema.org", "@type": "Person", - "url": "{{ "/" | absURL }}", + "url": "{{ "/" | relURL }}", "name": "{{ .Site.Params.title }}", "sameAs": [ "{{ .Site.Params.schemaTwitter | safeURL }}", @@ -35,10 +35,10 @@ { "@context": "https://schema.org", "@type": "WebSite", - "url": "{{ "/" | absURL }}", + "url": "{{ "/" | relURL }}", "potentialAction": { "@type": "SearchAction", - "target": "{{ "/" | absURL }}?q={search_term_string}", + "target": "{{ "/" | relURL }}?q={search_term_string}", "query-input": "required name=search_term_string" } } @@ -53,10 +53,10 @@ "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", - "@id": "{{ .Permalink }}" + "@id": "{{ .RelPermalink }}" }, "headline": "{{ .Title }}", - "image": [{{ range $i, $e := .Params.images }}{{ if $i }}, {{ end }}{{ printf "%s%s" $.Permalink $e }}{{ end }}], + "image": [{{ range $i, $e := .Params.images }}{{ if $i }}, {{ end }}{{ printf "%s%s" $.RelPermalink $e }}{{ end }}], "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}", "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}", "author": { @@ -69,7 +69,7 @@ {{ if eq .Site.Params.schemaType "Organization" -}} "logo": { "@type": "ImageObject", - "url": "{{ "/" | absURL }}{{ .Site.Params.schemaLogo }}" + "url": "{{ "/" | relURL }}{{ .Site.Params.schemaLogo }}" } {{ end -}} }, @@ -83,7 +83,7 @@ {{ $dot.Scratch.Set "path" "" -}} {{ $dot.Scratch.Set "breadcrumb" slice -}} -{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" -}} +{{ $url := replace .RelPermalink ( printf "%s" .Site.BaseURL) "" -}} {{ $.Scratch.Add "path" .Site.BaseURL -}} {{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}} diff --git a/layouts/partials/head/stylesheet.html b/layouts/partials/head/stylesheet.html index e5f9cc5..529e8f4 100644 --- a/layouts/partials/head/stylesheet.html +++ b/layouts/partials/head/stylesheet.html @@ -1,11 +1,11 @@ {{ if eq (hugo.Environment) "development" -}} {{ $options := (dict "targetPath" "main.css" "enableSourceMap" true "includePaths" (slice "node_modules")) -}} {{ $css := resources.Get "scss/app.scss" | toCSS $options -}} - + {{ else -}} {{ $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/head/twitter_cards.html b/layouts/partials/head/twitter_cards.html index d414116..8086253 100644 --- a/layouts/partials/head/twitter_cards.html +++ b/layouts/partials/head/twitter_cards.html @@ -1,6 +1,6 @@ {{ with $.Params.images -}} - + {{ else -}} {{ $images := $.Resources.ByType "image" -}} {{ $featured := $images.GetMatch "*feature*" -}} @@ -9,11 +9,11 @@ {{ end -}} {{ with $featured -}} - + {{ else -}} {{ with $.Site.Params.images -}} - + {{ else -}} {{ end -}} diff --git a/layouts/partials/header/header.html b/layouts/partials/header/header.html index 43d16b2..506d2ba 100644 --- a/layouts/partials/header/header.html +++ b/layouts/partials/header/header.html @@ -3,7 +3,7 @@
- {{ .Site.Params.Title }} + {{ .Site.Params.Title }} {{ if .Site.Params.options.darkMode -}}