Skip to content

Commit 6a134d4

Browse files
committed
Add option to configure portable links behaviour: off, error or warning
1 parent 7960aa3 commit 6a134d4

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

exampleSite/hugo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ enableGitInfo = true
136136
# /!\ This is an experimental feature, might be removed or changed at any time
137137
# (Optional, experimental, default false) Enables portable links and link checks in markdown pages.
138138
# Portable links meant to work with text editors and let you write markdown without {{< relref >}} shortcode
139-
# Theme will print warning if page referenced in markdown does not exists.
140-
BookPortableLinks = true
139+
# Theme will print warning or error if page referenced in markdown does not exists.
140+
# Possible values are false | 'warning' | 'error'
141+
BookPortableLinks = 'warning'
141142

142143
# /!\ This is an experimental feature, might be removed or changed at any time
143144
# (Optional, experimental, default false) Enables service worker that caches visited pages and resources for offline use.

exampleSite/hugo.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ params:
120120
# /!\ This is an experimental feature, might be removed or changed at any time
121121
# (Optional, experimental, default false) Enables portable links and link checks in markdown pages.
122122
# Portable links meant to work with text editors and let you write markdown without {{< relref >}} shortcode
123-
# Theme will print warning if page referenced in markdown does not exists.
124-
BookPortableLinks: true
123+
# Theme will print warning or error if page referenced in markdown does not exists.
124+
# Possible values are false | 'warning' | 'error'
125+
BookPortableLinks: 'warning'
125126

126127
# /!\ This is an experimental feature, might be removed or changed at any time
127128
# (Optional, experimental, default false) Enables service worker that caches visited pages and resources for offline use.

layouts/_partials/docs/links/portable-image.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
{{- else with (resources.Get $path) -}}
1414
{{- $destination = .RelPermalink -}}
1515
{{- else -}}
16-
{{- warnf "Image reference '%s' not found in '%s'" .Destination .Page.Permalink -}}
16+
{{- $mode := .Page.Site.Params.BookPortableLinks -}}
17+
{{- $message := printf "Image reference '%s' not found in '%s'" .Destination .Page.RelPermalink -}}
18+
{{- if eq $mode "warning" -}}
19+
{{- warnf $message -}}
20+
{{- else if eq $mode "error" -}}
21+
{{- errorf $message -}}
22+
{{- end -}}
1723
{{- end -}}
1824

1925
{{- with $url.RawQuery -}}

layouts/_partials/docs/links/portable-link.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
{{- else with (resources.Get $path) -}}
1717
{{- $destination = .RelPermalink -}}
1818
{{- else -}}
19-
{{- warnf "Reference '%s' not found in '%s'" .Destination .Page.RelPermalink -}}
19+
{{- $mode := .Page.Site.Params.BookPortableLinks -}}
20+
{{- $message := printf "Image reference '%s' not found in '%s'" .Destination .Page.RelPermalink -}}
21+
{{- if eq $mode "warning" -}}
22+
{{- warnf $message -}}
23+
{{- else if eq $mode "error" -}}
24+
{{- errorf $message -}}
25+
{{- end -}}
2026
{{- end -}}
2127

2228
{{- with $url.RawQuery -}}

0 commit comments

Comments
 (0)