aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/main.yml2
-rw-r--r--README.md8
-rw-r--r--exampleSite/config.toml6
-rw-r--r--exampleSite/config.yaml6
-rw-r--r--layouts/_default/_markup/render-image.html19
-rw-r--r--layouts/_default/_markup/render-link.html28
-rw-r--r--theme.toml2
7 files changed, 68 insertions, 3 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index a5ef8ac..699a0b9 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -25,7 +25,7 @@ jobs:
- name: Install Hugo
run: |
- wget "https://github.com/gohugoio/hugo/releases/download/v0.60.0/hugo_extended_0.60.0_Linux-64bit.deb" -O /tmp/hugo.deb
+ wget "https://github.com/gohugoio/hugo/releases/download/v0.62.0/hugo_extended_0.62.0_Linux-64bit.deb" -O /tmp/hugo.deb
sudo dpkg -i /tmp/hugo.deb
- name: Run Hugo
diff --git a/README.md b/README.md
index 1061ed4..942f37a 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Hugo Book Theme
-[![Hugo](https://img.shields.io/badge/hugo-0.60-blue.svg)](https://gohugo.io)
+[![Hugo](https://img.shields.io/badge/hugo-0.62-blue.svg)](https://gohugo.io)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
### [Hugo](https://gohugo.io) documentation theme as simple as plain book
@@ -178,6 +178,12 @@ disableKinds = ['taxonomy', 'taxonomyTerm']
# See https://gohugo.io/content-management/comments/#configure-disqus
# Can be overwritten by same param in page frontmatter
BookComments = true
+
+ # /!\ This is an experimental feature, might be removed or changed at any time
+ # (Optional, experimental, default false) Enables portable links and link checks in markdown pages.
+ # Portable links meant to work with text editors and let you write markdown without {{< relref >}} shortcode
+ # Theme will print warning if page referenced in markdown does not exists.
+ BookPortableLinks = true
```
### Multi-Language Support
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 65c9f0e..810ceab 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -90,3 +90,9 @@ enableGitInfo = true
# See https://gohugo.io/content-management/comments/#configure-disqus
# Can be overwritten by same param in page frontmatter
BookComments = true
+
+ # /!\ This is an experimental feature, might be removed or changed at any time
+ # (Optional, experimental, default false) Enables portable links and link checks in markdown pages.
+ # Portable links meant to work with text editors and let you write markdown without {{< relref >}} shortcode
+ # Theme will print warning if page referenced in markdown does not exists.
+ BookPortableLinks = true
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index 3c9cb45..f7f3bc2 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -86,3 +86,9 @@ params:
# See https://gohugo.io/content-management/comments/#configure-disqus
# Can be overwritten by same param in page frontmatter
BookComments: true
+
+ # /!\ This is an experimental feature, might be removed or changed at any time
+ # (Optional, experimental, default false) Enables portable links and link checks in markdown pages.
+ # Portable links meant to work with text editors and let you write markdown without {{< relref >}} shortcode
+ # Theme will print warning if page referenced in markdown does not exists.
+ BookPortableLinks: true
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
new file mode 100644
index 0000000..154e3a7
--- /dev/null
+++ b/layouts/_default/_markup/render-image.html
@@ -0,0 +1,19 @@
+{{ if .Page.Site.Params.BookPortableLinks }}
+ {{- template "portable-image" . -}}
+{{ else }}
+ <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }}title="{{ . }}"{{ end }}/>
+{{ end }}
+
+{{- define "portable-image" -}}
+ {{- $isRemote := or (in .Destination "://") (strings.HasPrefix .Destination "//") }}
+ {{- if not $isRemote }}
+ {{- $path := print .Page.File.Dir .Destination }}
+ {{- if strings.HasPrefix .Destination "/" }}
+ {{- $path = print "/static" .Destination }}
+ {{- end }}
+ {{- if not (fileExists $path) }}
+ {{- warnf "Image '%s' not found in '%s'" .Destination .Page.File }}
+ {{- end }}
+ {{- end }}
+ <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }}title="{{ . }}"{{ end }}/>
+{{- end -}}
diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
new file mode 100644
index 0000000..48b419f
--- /dev/null
+++ b/layouts/_default/_markup/render-link.html
@@ -0,0 +1,28 @@
+{{ if .Page.Site.Params.BookPortableLinks }}
+ {{- template "portable-link" . -}}
+{{ else }}
+ <a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
+{{ end }}
+
+{{- define "portable-link" -}}
+ {{- $destination := .Destination }}
+ {{- $isRemote := or (in .Destination "://") (strings.HasPrefix .Destination "//") }}
+ {{- if not $isRemote }}
+ {{- $url := urls.Parse .Destination }}
+ {{- $path := strings.TrimSuffix "/_index.md" $url.Path }}
+ {{- $path = strings.TrimSuffix "/_index" $path }}
+ {{- $path = strings.TrimSuffix ".md" $path }}
+ {{- $page := .Page.GetPage $path }}
+ {{- if $page }}
+ {{- $destination = $page.RelPermalink }}
+ {{- if $url.Fragment }}
+ {{- $destination = print $destination "#" $url.Fragment }}
+ {{- end }}
+ {{- else if fileExists (print .Page.File.Dir .Destination) }}
+ <!-- Nothing -->
+ {{- else -}}
+ {{- warnf "Page '%s' not found in '%s'" .Destination .Page.File }}
+ {{- end }}
+ {{- end }}
+ <a href="{{ $destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
+{{- end -}}
diff --git a/theme.toml b/theme.toml
index 94b5ee2..b424f14 100644
--- a/theme.toml
+++ b/theme.toml
@@ -8,7 +8,7 @@ description = "Hugo documentation theme as simple as plain book"
homepage = "https://github.com/alex-shpak/hugo-book"
tags = ["responsive", "clean", "documentation", "docs", "flexbox", "search", "mobile", "multilingual", "disqus"]
features = []
-min_version = "0.60"
+min_version = "0.62"
[author]
name = "Alex Shpak"