Refactor theme to use relative urls everywhere

This commit is contained in:
Alex Shpak 2019-02-20 10:37:48 +01:00
parent 0cfb8a08a4
commit eb67ab58aa
6 changed files with 20 additions and 20 deletions

View file

@ -2,12 +2,12 @@
headless: true headless: true
--- ---
- [**Introduction**]({{< ref "/" >}}) - [**Introduction**]({{< relref "/" >}})
- [Examples]({{< ref "/docs/examples.md" >}}) - [Examples]({{< relref "/docs/examples.md" >}})
- [With Table of contents]({{< ref "/docs/with-toc.md" >}}) - [With Table of contents]({{< relref "/docs/with-toc.md" >}})
- [Without Table of Contents]({{< ref "/docs/without-toc.md" >}}) - [Without Table of Contents]({{< relref "/docs/without-toc.md" >}})
- **More Examples** - **More Examples**
- [Server]({{< ref "/docs/server.md" >}}) - [Server]({{< relref "/docs/server.md" >}})
- [Client]({{< ref "/docs/client.md" >}}) - [Client]({{< relref "/docs/client.md" >}})
- [Advanced]({{< ref "/docs/advanced.md" >}}) - [Advanced]({{< relref "/docs/advanced.md" >}})
- [**Blog**]({{< ref "/posts" >}}) - [**Blog**]({{< relref "/posts" >}})

View file

@ -3,14 +3,14 @@
{{ with .GitInfo }} {{ with .GitInfo }}
<div> <div>
<a href="{{ $.Site.Params.BookRepo }}/commit/{{ .Hash }}" title='Last modified {{ .AuthorDate.Local.Format "January 2, 2006 15:04 MST" }} by {{ .AuthorName }}' target="_blank" rel="noopener"> <a href="{{ $.Site.Params.BookRepo }}/commit/{{ .Hash }}" title='Last modified {{ .AuthorDate.Local.Format "January 2, 2006 15:04 MST" }} by {{ .AuthorName }}' target="_blank" rel="noopener">
<img src="{{ "svg/code-merge.svg" | absURL }}" /> {{ .AuthorDate.Local.Format "Last Modified Jan 2, 2006" }} <img src="{{ "svg/code-merge.svg" | relURL }}" /> {{ .AuthorDate.Local.Format "Last Modified Jan 2, 2006" }}
</a> </a>
</div> </div>
{{ end }} {{ end }}
{{ with .Site.Params.BookEditPath }} {{ with .Site.Params.BookEditPath }}
<div> <div>
<a href="{{ $.Site.Params.BookRepo }}/{{ . }}/{{ $.File.Path }}" target="_blank" rel="noopener"> <a href="{{ $.Site.Params.BookRepo }}/{{ . }}/{{ $.File.Path }}" target="_blank" rel="noopener">
<img src="{{ "svg/code-fork.svg" | absURL }}" /> Edit this page <img src="{{ "svg/code-fork.svg" | relURL }}" /> Edit this page
</a> </a>
</div> </div>
{{ end }} {{ end }}

View file

@ -3,7 +3,7 @@
<title>{{- template "title" . }} | {{ .Site.Title -}}</title> <title>{{- template "title" . }} | {{ .Site.Title -}}</title>
<link href="https://fonts.googleapis.com/css?family=Oxygen|Oxygen+Mono:300,400,700" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Oxygen|Oxygen+Mono:300,400,700" rel="stylesheet">
<link rel="stylesheet" href="{{ "normalize.min.css" | absURL }}"> <link rel="stylesheet" href="{{ "normalize.min.css" | relURL }}">
{{ $styles := resources.Get "book.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }} {{ $styles := resources.Get "book.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}"> <link rel="stylesheet" href="{{ $styles.RelPermalink }}">

View file

@ -1,6 +1,6 @@
<header class="align-center justify-between book-header"> <header class="align-center justify-between book-header">
<label for="menu-control"> <label for="menu-control">
<img src="{{ "svg/menu.svg" | absURL }}" /> <img src="{{ "svg/menu.svg" | relURL }}" />
</label> </label>
<strong>{{- template "title" . }}</strong> <strong>{{- template "title" . }}</strong>
</header> </header>

View file

@ -1,5 +1,5 @@
{{/*These templates contains some more complex logic and shared between partials*/}} {{/*These templates contains some more complex logic and shared between partials*/}}
{{ define "title" }} {{- define "title" -}}
{{- if .Pages -}} {{- if .Pages -}}
{{ $sections := split (trim .Dir "/") "/" }} {{ $sections := split (trim .Dir "/") "/" }}
{{ $title := index ($sections | last 1) 0 | humanize | title }} {{ $title := index ($sections | last 1) 0 | humanize | title }}
@ -8,9 +8,9 @@
{{ $title := .File | humanize | title }} {{ $title := .File | humanize | title }}
{{- default $title .Title -}} {{- default $title .Title -}}
{{- end -}} {{- end -}}
{{ end }} {{- end -}}
{{ define "hrefhack" }} {{- define "hrefhack" -}}
{{ $attrEq := "$=" }} {{ $attrEq := "$=" }}
{{ $attrVal := .RelPermalink }} {{ $attrVal := .RelPermalink }}
{{ if eq .RelPermalink "/" }} {{ if eq .RelPermalink "/" }}
@ -23,9 +23,9 @@
color: {{ default "#004ed0" .Site.Params.BookMenuBundleActiveLinkColor }}; color: {{ default "#004ed0" .Site.Params.BookMenuBundleActiveLinkColor }};
} }
</style> </style>
{{ end }} {{- end -}}
{{ define "jsmenu" }} {{- define "jsmenu" -}}
<script> <script>
(function() { (function() {
var menu = document.querySelector('aside.book-menu nav') var menu = document.querySelector('aside.book-menu nav')
@ -36,4 +36,4 @@
menu.scrollTop = localStorage.getItem('menu.scrollTop') menu.scrollTop = localStorage.getItem('menu.scrollTop')
})() })()
</script> </script>
{{ end }} {{- end -}}

View file

@ -3,7 +3,7 @@
{{ range sort .Paginator.Pages }} {{ range sort .Paginator.Pages }}
<article> <article>
<h2> <h2>
<a href="{{ .Permalink }}">{{ .Title }}</a> <a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h2> </h2>
<h5> <h5>
<strong>{{ .Date.Format "January 2, 2006" }}</strong> <strong>{{ .Date.Format "January 2, 2006" }}</strong>
@ -11,7 +11,7 @@
<p class="markdown"> <p class="markdown">
{{- .Summary -}} {{- .Summary -}}
{{ if .Truncated }} {{ if .Truncated }}
<a href="{{ .Permalink }}">...</a> <a href="{{ .RelPermalink }}">...</a>
{{ end }} {{ end }}
</p> </p>
</article> </article>