@@ -95,7 +95,7 @@ export class SearchWidget {
}
html += matches.map((result) => {
const { section, title, heading, url } = result.original;
- const anchor = heading !== title ? '#' + heading.toLowerCase().replace(/\s/g, '-') : '';
+ const anchor = heading !== title ? '#' + this.headingToAnchor(heading) : '';
const inner = `<div class="title">${title}</div><div class="heading">${result.string}</div>`;
const selected = i === this.selectedIndex ? 'selected' : '';
i++;
@@ -195,4 +195,10 @@ export class SearchWidget {
return this.searchIndex;
+
+ private headingToAnchor(heading: string): string {
+ return heading.toLowerCase()
+ .replace(/\s/g, '-')
+ .replace(/[:]/g, '');
+ }
@@ -1,11 +1,12 @@
{
result :[
- {{- range .Site.Pages -}}
+ {{- range .Site.RegularPages -}}
{{ $titles := findRE "<h(2|3).*?>(.|\n)*?</h(2|3)>" .Content -}}
{{ $plain := apply $titles "plainify" "." -}}
{{ $cleaned := $plain | complement (slice "constructor" "Signature" "Members") -}}
{{ $quoted := apply $cleaned "replaceRE" ".*" "'$0'" "." -}}
{{ $section := cond (in .Dir "configuration") "config" (cond (in .Dir "graphql-api") "gql" "guides") }}
{ section: '{{ $section }}', title: '{{ .Title }}', headings: [{{ delimit $quoted ", " }}], url: '{{ .RelPermalink }}' },
{{- end }}
]