|
18 | 18 | {{- $permalink = .Destination }} |
19 | 19 | {{- end }} |
20 | 20 | {{- else }} |
| 21 | + {{- $currentFile := .Page.File.Path }} |
21 | 22 | {{- $isOnlyFragment := findRE `(?m)^#` $link }} |
22 | 23 | {{- 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 }} |
| 24 | + {{- if not (.Page.Fragments.Identifiers.Contains $url.Fragment) }} |
29 | 25 | {{- 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 ", ") }} |
| 26 | + {{- errorf "<error code=1> Broken anchor link '%v' found in %s, available anchors: %v </error><br>" $fragment $currentFile (delimit .Page.Fragments.Identifiers ", ") }} |
31 | 27 | {{- else }} |
32 | | - {{- warnf "Broken anchor link '%v' found in %s, available anchors: %v" $fragment $currentPage (delimit $fragments ", ") }} |
| 28 | + {{- warnf "Broken anchor link '%v' found in %s, available anchors: %v" $fragment $currentPage (delimit .Page.Fragments.Identifiers ", ") }} |
33 | 29 | {{- end }} |
34 | 30 | {{- end }} |
35 | 31 | {{- $permalink = $fragment }} |
36 | 32 | {{- else }} |
37 | 33 | {{- $page := .Page.GetPage $path }} |
38 | | - {{- with $page }} |
| 34 | + {{- if $page }} |
| 35 | + {{- if and $fragment (not (strings.HasSuffix $path "arangodb-server/options.md")) (not (strings.HasSuffix $path "query-optimization.md")) (not ($page.Fragments.Identifiers.Contains $url.Fragment)) }} |
| 36 | + {{- if site.Params.failOnBrokenLinks }} |
| 37 | + {{- errorf "<error code=1> Broken anchor link '%v%v' found in %s, available anchors: %v </error><br>" $path $fragment $currentFile (delimit $page.Fragments.Identifiers ", ") }} |
| 38 | + {{- else }} |
| 39 | + {{- warnf "Broken anchor link '%v%v' found in %s, available anchors: %v" $path $fragment $currentPage (delimit $page.Fragments.Identifiers ", ") }} |
| 40 | + {{- end }} |
| 41 | + {{- end }} |
39 | 42 | {{- $permalink = printf "%s%s" $page.RelPermalink $fragment }} |
40 | 43 | {{- else }} |
41 | 44 | {{- if ne $currentPage "/" }} |
42 | | - {{- $currentFile := .Page.File.Path }} |
43 | 45 | {{- if site.Params.failOnBrokenLinks }} |
44 | 46 | {{- errorf "<error code=1> Broken link '%v' found in %s </error><br>" $link $currentFile }} |
45 | 47 | {{- else }} |
|
0 commit comments