Skip to content

Commit

Permalink
feat: update for netlify dev support
Browse files Browse the repository at this point in the history
  • Loading branch information
h-enk committed Apr 2, 2021
1 parent 73cc633 commit 10d0b45
Show file tree
Hide file tree
Showing 37 changed files with 112 additions and 102 deletions.
2 changes: 1 addition & 1 deletion assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 2 additions & 1 deletion config/_default/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
baseurl = "/"
canonifyURLs = false
disableAliases = true
disableHugoGeneratorInject = true
enableEmoji = true
Expand Down Expand Up @@ -72,7 +73,7 @@ rel = "sitemap"
[taxonomies]
contributor = "contributors"

[permalinks]
[RelPermalinks]
blog = "/blog/:title/"

[module]
Expand Down
2 changes: 2 additions & 0 deletions config/next/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
baseurl = "https://doks-next.netlify.app/"
canonifyURLs = true
3 changes: 2 additions & 1 deletion config/production/config.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
baseurl = "/"
baseurl = "https://doks.netlify.app/"
canonifyURLs = true
Empty file removed config/staging/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions content/docs/prologue/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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" >}})
2 changes: 1 addition & 1 deletion content/docs/prologue/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}})
2 changes: 1 addition & 1 deletion content/privacy-policy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_
2 changes: 1 addition & 1 deletion layouts/_default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var docs = [
id: {{ $index }},
title: "{{ .Title }}",
description: "{{ .Params.description }}",
href: "{{ .URL | absURL }}"
href: "{{ .URL | relURL }}"
},
{{ end -}}
];
2 changes: 1 addition & 1 deletion layouts/_default/index.json
Original file line number Diff line number Diff line change
@@ -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 -}}
2 changes: 1 addition & 1 deletion layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="col-md-12 col-lg-10 col-xl-8">
{{ range .Paginator.Pages }}
<article>
<h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ .Description }}
</article>
{{ end }}
Expand Down
12 changes: 6 additions & 6 deletions layouts/_default/section.sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
{{ range $i, $e := .Data.Pages -}}
{{ if ne .Params.sitemap_exclude true }}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<loc>{{ .RelPermalink }}</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 }}"
href="{{ .RelPermalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
href="{{ .RelPermalink }}"
/>{{ end }}
</url>
{{ end -}}
Expand All @@ -25,19 +25,19 @@
{{ range $i, $e := .Data.Pages -}}
{{ if ne .Params.sitemap_exclude true -}}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<loc>{{ .RelPermalink }}</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 }}"
href="{{ .RelPermalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
href="{{ .RelPermalink }}"
/>{{ end }}
</url>
{{ end -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/blog/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<h1 class="text-center">{{ .Title }}</h1>
<div class="text-center">{{ .Content }}</div>
<div class="card-list">
{{ range .Data.Pages -}}
{{ range .Data.Pages -}}
<div class="card">
<div class="card-body">
<h2 class="h3"><a class="stretched-link text-body" href="{{ .Permalink }}">{{ .Params.title }}</a></h2>
<h2 class="h3"><a class="stretched-link text-body" href="{{ .RelPermalink }}">{{ .Params.title }}</a></h2>
<p>{{ .Params.lead | safeHTML }}</p>
{{ partial "main/blog-meta.html" . -}}
</div>
Expand Down
4 changes: 2 additions & 2 deletions layouts/contributors/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<article>
<h1 class="text-center">{{ .Title }}</h1>
<div class="text-center">{{ .Content }}</div>
<div class="card-list">
<div class="card-list">
{{ range .Data.Pages -}}
<div class="card">
<div class="card-body">
<h2 class="h3"><a class="stretched-link text-body" href="{{ .Permalink }}">{{ .Params.title }}</a></h2>
<h2 class="h3"><a class="stretched-link text-body" href="{{ .RelPermalink }}">{{ .Params.title }}</a></h2>
{{ if eq .Section "blog" -}}
<p>{{ .Params.lead | safeHTML }}</p>
{{ partial "main/blog-meta.html" . -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/docs/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ <h1 class="text-center">{{ .Title }}</h1>
<div class="card-list">
{{ $currentSection := .CurrentSection }}
{{ range where .Site.RegularPages.ByTitle "Section" .Section }}
{{ if in (.Permalink | string) $currentSection.RelPermalink }}
{{ if in (.RelPermalink | string) $currentSection.RelPermalink }}
<div class="card my-3">
<div class="card-body">
<a class="stretched-link" href="{{ .Permalink }}">{{ .Params.title | title }} &rarr;</a>
<a class="stretched-link" href="{{ .RelPermalink }}">{{ .Params.title | title }} &rarr;</a>
</div>
</div>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1 class="mt-0">{{ .Title }}</h1>
</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/" | absURL }}" role="button">Get started</a>
<a class="btn btn-primary btn-lg px-4 mb-2" href="{{ "docs/prologue/introduction/" | relURL }}" role="button">Get started</a>
<p class="meta">Open-source MIT Licensed. <a href="https://github.com/h-enk/doks">GitHub v{{ .Site.Data.doks.version }}</a></p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion layouts/index.redirects
Original file line number Diff line number Diff line change
@@ -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 -}}
2 changes: 1 addition & 1 deletion layouts/partials/footer/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="col-lg-8 order-first order-lg-last text-lg-end">
<ul class="list-inline">
{{ range .Site.Menus.footer -}}
<li class="list-inline-item"><a href="{{ .URL | absURL }}">{{ .Name }}</a></li>
<li class="list-inline-item"><a href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end -}}
</ul>
</div>
Expand Down
24 changes: 12 additions & 12 deletions layouts/partials/footer/script-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@

{{ if eq (hugo.Environment) "development" -}}
{{ if .Site.Params.options.bootStrapJs -}}
<script src="{{ $bs.Permalink }}" defer></script>
<script src="{{ $bs.RelPermalink }}" defer></script>
{{ end -}}
{{ if .Site.Params.options.highLight -}}
<script src="{{ $highlight.Permalink }}" defer></script>
<script src="{{ $highlight.RelPermalink }}" defer></script>
{{ end -}}
{{ if .Site.Params.options.kaTex -}}
<script src="{{ $katex.Permalink }}" defer></script>
<script src="{{ $katexAutoRender.Permalink }}" onload="renderMathInElement(document.body);" defer></script>
<script src="{{ $katex.RelPermalink }}" defer></script>
<script src="{{ $katexAutoRender.RelPermalink }}" onload="renderMathInElement(document.body);" defer></script>
{{ end -}}
<script src="{{ $js.Permalink }}" defer></script>
<script src="{{ $js.RelPermalink }}" defer></script>
{{ if .Site.Params.options.flexSearch -}}
<script src="{{ $index.Permalink }}" defer></script>
<script src="{{ $index.RelPermalink }}" defer></script>
{{ end -}}
{{ else -}}
{{ $js := $js | minify | fingerprint "sha512" -}}
Expand All @@ -74,17 +74,17 @@
{{ $katex := $katex | minify | fingerprint "sha512" -}}
{{ $katexAutoRender := $katexAutoRender | minify | fingerprint "sha512" -}}
{{ if .Site.Params.options.bootStrapJs -}}
<script src="{{ $bs.Permalink }}" integrity="{{ $bs.Data.Integrity }}" crossorigin="anonymous" defer></script>
<script src="{{ $bs.RelPermalink }}" integrity="{{ $bs.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
{{ if .Site.Params.options.highLight -}}
<script src="{{ $highlight.Permalink }}" integrity="{{ $highlight.Data.Integrity }}" crossorigin="anonymous" defer></script>
<script src="{{ $highlight.RelPermalink }}" integrity="{{ $highlight.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
{{ if .Site.Params.options.kaTex -}}
<script src="{{ $katex.Permalink }}" integrity="{{ $katex.Data.Integrity }}" crossorigin="anonymous" defer></script>
<script src="{{ $katexAutoRender.Permalink }}" integrity="{{ $katexAutoRender.Data.Integrity }}" crossorigin="anonymous" defer></script>
<script src="{{ $katex.RelPermalink }}" integrity="{{ $katex.Data.Integrity }}" crossorigin="anonymous" defer></script>
<script src="{{ $katexAutoRender.RelPermalink }}" integrity="{{ $katexAutoRender.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
<script src="{{ $js.Permalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous" defer></script>
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ if .Site.Params.options.flexSearch -}}
<script src="{{ $index.Permalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script>
<script src="{{ $index.RelPermalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script>
{{ end -}}
{{ end -}}
8 changes: 4 additions & 4 deletions layouts/partials/head/favicons.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<meta name="theme-color" content="{{ $.Site.Params.themeColor }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | absURL }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | absURL }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | absURL }}">
<link rel="manifest" href="{{ "site.webmanifest" | absURL }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | relURL }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | relURL }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | relURL }}">
<link rel="manifest" href="{{ "site.webmanifest" | relURL }}">
18 changes: 9 additions & 9 deletions layouts/partials/head/opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
{{ if $.Scratch.Get "paginator" -}}
{{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "blog" ) -}}
<meta property="og:url" content="{{ .Paginator.URL | absURL }}">
<meta property="og:url" content="{{ .Paginator.URL | relURL }}">
{{ else -}}
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:url" content="{{ .RelPermalink }}">
{{ end -}}

{{ with $.Params.images -}}
{{ range first 6 . -}}
<meta property="og:image" content="{{ $.Permalink }}{{ . }}">
<meta property="og:image" content="{{ $.RelPermalink }}{{ . }}">
{{ end -}}
{{ else -}}
{{ $images := $.Resources.ByType "image" -}}
Expand All @@ -19,10 +19,10 @@
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ end -}}
{{ with $featured -}}
<meta property="og:image" content="{{ $featured.Permalink }}"/>
<meta property="og:image" content="{{ $featured.RelPermalink }}"/>
{{ else -}}
{{ with $.Site.Params.images -}}
<meta property="og:image" content="{{ index . 0 | absURL }}"/>
<meta property="og:image" content="{{ index . 0 | relURL }}"/>
{{ end -}}
{{ end -}}
{{ end -}}
Expand Down Expand Up @@ -54,18 +54,18 @@
{{ end -}}
{{ with .Params.videos -}}
{{ range . -}}
<meta property="og:video" content="{{ . | absURL }}">
<meta property="og:video" content="{{ . | relURL }}">
{{ 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 -}}
<meta property="og:see_also" content="{{ $page.Permalink }}">
{{ if ne $page.RelPermalink $RelPermalink -}}
<meta property="og:see_also" content="{{ $page.RelPermalink }}">
{{ end -}}
{{ end -}}
{{ end -}}
Expand Down
8 changes: 4 additions & 4 deletions layouts/partials/head/resource-hints.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<link rel="preload" as="font" href="{{ "fonts/vendor/jost/jost-v4-latin-regular.woff2" | absURL }}" type="font/woff2" crossorigin>
<link rel="preload" as="font" href="{{ "fonts/vendor/jost/jost-v4-latin-700.woff2" | absURL }}" type="font/woff2" crossorigin>
<link rel="preload" as="font" href="{{ "fonts/vendor/jost/jost-v4-latin-regular.woff2" | relURL }}" type="font/woff2" crossorigin>
<link rel="preload" as="font" href="{{ "fonts/vendor/jost/jost-v4-latin-700.woff2" | relURL }}" type="font/woff2" crossorigin>
{{ if .Site.Params.options.kaTex -}}
<link rel="preload" as="font" href="{{ "fonts/KaTeX_Main-Regular.woff2" | absURL }}" type="font/woff2" crossorigin>
<link rel="preload" as="font" href="{{ "fonts/KaTeX_Math-Italic.woff2" | absURL }}" type="font/woff2" crossorigin>
<link rel="preload" as="font" href="{{ "fonts/KaTeX_Main-Regular.woff2" | relURL }}" type="font/woff2" crossorigin>
<link rel="preload" as="font" href="{{ "fonts/KaTeX_Math-Italic.woff2" | relURL }}" type="font/woff2" crossorigin>
{{ end -}}
10 changes: 5 additions & 5 deletions layouts/partials/head/seo.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
{{ end -}}

{{ if $.Scratch.Get "paginator" }}
<link rel="canonical" href="{{ .Paginator.URL | absURL }}">
<link rel="canonical" href="{{ .Paginator.URL | relURL }}">
{{ if .Paginator.HasPrev -}}
<link rel="prev" href="{{ .Paginator.Prev.URL | absURL }}">
<link rel="prev" href="{{ .Paginator.Prev.URL | relURL }}">
{{ end -}}
{{ if .Paginator.HasNext -}}
<link rel="next" href="{{ .Paginator.Next.URL | absURL }}">
<link rel="next" href="{{ .Paginator.Next.URL | relURL }}">
{{ end -}}
{{ else -}}
<link rel="canonical" href="{{ .Permalink }}">
<link rel="canonical" href="{{ .RelPermalink }}">
{{ end -}}

{{ partial "head/twitter_cards.html" . }}
Expand All @@ -44,7 +44,7 @@
<meta property="og:locale" content="{{ .Site.Params.ogLocale }}">

{{ range .AlternativeOutputFormats -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .RelPermalink | safeURL }}">
{{ end -}}

{{ partial "head/structured-data.html" . }}
Loading

0 comments on commit 10d0b45

Please sign in to comment.