Skip to content

Commit 814c0b6

Browse files
committed
Add check for same page anchor links
1 parent d68852a commit 814c0b6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

site/themes/arangodb-docs-theme/layouts/_default/_markup/render-link.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
2020
{{- else }}
2121
{{- $isOnlyFragment := findRE `(?m)^#` $link }}
2222
{{- if $isOnlyFragment }}
23+
{{- $fragments := slice }}
24+
{{- range $k, $v := .Page.Fragments.HeadingsMap }}
25+
{{- $fragments = $fragments | append $k }}
26+
{{- end }}
27+
{{- if not (in $fragments (strings.TrimPrefix "#" $fragment)) }}
28+
{{- $currentFile := .Page.File.Path }}
29+
{{- if site.Params.failOnBrokenLinks }}
30+
{{- errorf "<error code=1> Broken anchor link '%v' found in %s, available anchors: %v </error><br>" $fragment $currentFile (delimit $fragments ", ") }}
31+
{{- else }}
32+
{{- warnf "Broken anchor link '%v' found in %s, available anchors: %v" $fragment $currentPage (delimit $fragments ", ") }}
33+
{{- end }}
34+
{{- end }}
2335
{{- $permalink = $fragment }}
2436
{{- else }}
2537
{{- $page := .Page.GetPage $path }}

0 commit comments

Comments
 (0)