Merge branch 'master' of github.com:h-enk/doks
This commit is contained in:
commit
f5d1bae87c
|
@ -108,7 +108,7 @@ Source:
|
||||||
{{ else -}}
|
{{ else -}}
|
||||||
description: {{ .Summary | plainify | jsonify }},
|
description: {{ .Summary | plainify | jsonify }},
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
content: {{ .Content | jsonify }}
|
content: {{ .Plain | jsonify }}
|
||||||
})
|
})
|
||||||
{{ if ne (add $index 1) $len -}}
|
{{ if ne (add $index 1) $len -}}
|
||||||
.add(
|
.add(
|
||||||
|
@ -117,47 +117,53 @@ Source:
|
||||||
;
|
;
|
||||||
|
|
||||||
search.addEventListener('input', show_results, true);
|
search.addEventListener('input', show_results, true);
|
||||||
suggestions.addEventListener('click', accept_suggestion, true);
|
|
||||||
|
|
||||||
function show_results(){
|
function show_results(){
|
||||||
const maxResult = 5;
|
const maxResult = 5;
|
||||||
|
var searchQuery = this.value;
|
||||||
|
var results = index.search(searchQuery, {limit: maxResult, enrich: true});
|
||||||
|
|
||||||
var value = this.value;
|
// flatten results since index.search() returns results for each indexed field
|
||||||
var results = index.search(value, {limit: maxResult, enrich: true});
|
const flatResults = new Map(); // keyed by href to dedupe results
|
||||||
|
|
||||||
suggestions.classList.remove('d-none');
|
|
||||||
suggestions.innerHTML = "";
|
|
||||||
|
|
||||||
//flatSearch now returns results for each index field. create a single list
|
|
||||||
const flatResults = {}; //keyed by href to dedupe results
|
|
||||||
for (const result of results.flatMap(r => r.result)) {
|
for (const result of results.flatMap(r => r.result)) {
|
||||||
flatResults[result.doc.href] = result.doc;
|
if (flatResults.has(result.doc.href)) continue;
|
||||||
|
flatResults.set(result.doc.href, result.doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//construct a list of suggestions list
|
suggestions.innerHTML = "";
|
||||||
for(const href in flatResults) {
|
suggestions.classList.remove('d-none');
|
||||||
const doc = flatResults[href];
|
|
||||||
|
|
||||||
|
// inform user that no results were found
|
||||||
|
if (flatResults.size === 0 && searchQuery) {
|
||||||
|
const noResultsMessage = document.createElement('div')
|
||||||
|
noResultsMessage.innerHTML = `No results for "<strong>${searchQuery}</strong>"`
|
||||||
|
noResultsMessage.classList.add("suggestion__no-results");
|
||||||
|
suggestions.appendChild(noResultsMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// construct a list of suggestions
|
||||||
|
for(const [href, doc] of flatResults) {
|
||||||
const entry = document.createElement('div');
|
const entry = document.createElement('div');
|
||||||
entry.innerHTML = '<a href><span></span><span></span></a>';
|
suggestions.appendChild(entry);
|
||||||
|
|
||||||
entry.querySelector('a').href = href;
|
const a = document.createElement('a');
|
||||||
entry.querySelector('span:first-child').textContent = doc.title;
|
a.href = href;
|
||||||
entry.querySelector('span:nth-child(2)').textContent = doc.description;
|
entry.appendChild(a);
|
||||||
|
|
||||||
|
const title = document.createElement('span');
|
||||||
|
title.textContent = doc.title;
|
||||||
|
title.classList.add("suggestion__title");
|
||||||
|
a.appendChild(title);
|
||||||
|
|
||||||
|
const description = document.createElement('span');
|
||||||
|
description.textContent = doc.description;
|
||||||
|
description.classList.add("suggestion__description");
|
||||||
|
a.appendChild(description);
|
||||||
|
|
||||||
suggestions.appendChild(entry);
|
suggestions.appendChild(entry);
|
||||||
|
|
||||||
if(suggestions.childElementCount == maxResult) break;
|
if(suggestions.childElementCount == maxResult) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function accept_suggestion(){
|
|
||||||
|
|
||||||
while(suggestions.lastChild){
|
|
||||||
|
|
||||||
suggestions.removeChild(suggestions.lastChild);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -10,11 +10,15 @@
|
||||||
z-index: $zindex-dropdown;
|
z-index: $zindex-dropdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#suggestions a,
|
||||||
|
.suggestion__no-results {
|
||||||
|
padding: 0.75rem;
|
||||||
|
margin: 0 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
#suggestions a {
|
#suggestions a {
|
||||||
display: block;
|
display: block;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
padding: 0.75rem;
|
|
||||||
margin: 0 0.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#suggestions a:focus {
|
#suggestions a:focus {
|
||||||
|
@ -43,12 +47,13 @@
|
||||||
font-size: $font-size-base;
|
font-size: $font-size-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
#suggestions span:first-child {
|
.suggestion__title {
|
||||||
font-weight: $headings-font-weight;
|
font-weight: $headings-font-weight;
|
||||||
color: $black;
|
color: $black;
|
||||||
}
|
}
|
||||||
|
|
||||||
#suggestions span:nth-child(2) {
|
.suggestion__description,
|
||||||
|
.suggestion__no-results {
|
||||||
color: $gray-700;
|
color: $gray-700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +66,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
#suggestions span:first-child {
|
.suggestion__title {
|
||||||
width: 9rem;
|
width: 9rem;
|
||||||
padding-right: 1rem;
|
padding-right: 1rem;
|
||||||
border-right: 1px solid $gray-200;
|
border-right: 1px solid $gray-200;
|
||||||
|
@ -69,7 +74,7 @@
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#suggestions span:nth-child(2) {
|
.suggestion__description {
|
||||||
width: 19rem;
|
width: 19rem;
|
||||||
padding-left: 1rem;
|
padding-left: 1rem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} <a href="#{{ .Anchor | safeURL }}" class="anchor" aria-hidden="true">#</a></h{{ .Level }}>
|
|
@ -31,7 +31,7 @@
|
||||||
{{ partial "sidebar/docs-toc.html" . }}
|
{{ partial "sidebar/docs-toc.html" . }}
|
||||||
</nav>
|
</nav>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ partial "main/headline-hash.html" .Content }}
|
{{ .Content }}
|
||||||
{{ if .Site.Params.editPage -}}
|
{{ if .Site.Params.editPage -}}
|
||||||
{{ partial "main/edit-page.html" . }}
|
{{ partial "main/edit-page.html" . }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
@ -45,4 +45,4 @@
|
||||||
-->
|
-->
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
{{ . | replaceRE "(<h[2-9] id=\"([^\"]+)\".+)(</h[2-9]+>)" `${1}<a href="#${2}" class="anchor" aria-hidden="true">#</a> ${3}` | safeHTML }}
|
|
|
@ -3710,9 +3710,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/dompurify": {
|
"node_modules/dompurify": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.3.tgz",
|
||||||
"integrity": "sha512-xGWt+NHAQS+4tpgbOAI08yxW0Pr256Gu/FNE2frZVTbgrBUn8M7tz7/ktS/LZ2MHeGqz6topj0/xY+y8R5FBFw==",
|
"integrity": "sha512-dqnqRkPMAjOZE0FogZ+ceJNM2dZ3V/yNOuFB7+39qpO93hHhfRpHw3heYQC7DPK9FqbQTfBKUJhiSfz4MvXYwg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/domutils": {
|
"node_modules/domutils": {
|
||||||
|
@ -5914,16 +5914,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mermaid": {
|
"node_modules/mermaid": {
|
||||||
"version": "8.13.2",
|
"version": "8.13.3",
|
||||||
"resolved": "https://registry.npmjs.org/mermaid/-/mermaid-8.13.2.tgz",
|
"resolved": "https://registry.npmjs.org/mermaid/-/mermaid-8.13.3.tgz",
|
||||||
"integrity": "sha512-qTFI7MfC2d+x0Hft5gx063EH9tZg36lERG8o7Zq0Ag+MnO8CgVaMZEU6oA8gzTtTn9upMdy4UlYSLVmavu27cQ==",
|
"integrity": "sha512-w6KmDtSzkk856WUVqlBsyLZX0q4Jr35IlxiHTPTaWwMgWHFpI8rEJzcxWoyrpxeT/Rac/vvvSFOZymDTeA0iiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^3.1.0",
|
"@braintree/sanitize-url": "^3.1.0",
|
||||||
"d3": "^7.0.0",
|
"d3": "^7.0.0",
|
||||||
"dagre": "^0.8.5",
|
"dagre": "^0.8.5",
|
||||||
"dagre-d3": "^0.6.4",
|
"dagre-d3": "^0.6.4",
|
||||||
"dompurify": "2.3.1",
|
"dompurify": "2.3.3",
|
||||||
"graphlib": "^2.1.8",
|
"graphlib": "^2.1.8",
|
||||||
"khroma": "^1.4.1",
|
"khroma": "^1.4.1",
|
||||||
"moment-mini": "^2.24.0",
|
"moment-mini": "^2.24.0",
|
||||||
|
@ -11334,9 +11334,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dompurify": {
|
"dompurify": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.3.tgz",
|
||||||
"integrity": "sha512-xGWt+NHAQS+4tpgbOAI08yxW0Pr256Gu/FNE2frZVTbgrBUn8M7tz7/ktS/LZ2MHeGqz6topj0/xY+y8R5FBFw==",
|
"integrity": "sha512-dqnqRkPMAjOZE0FogZ+ceJNM2dZ3V/yNOuFB7+39qpO93hHhfRpHw3heYQC7DPK9FqbQTfBKUJhiSfz4MvXYwg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"domutils": {
|
"domutils": {
|
||||||
|
@ -13009,16 +13009,16 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"mermaid": {
|
"mermaid": {
|
||||||
"version": "8.13.2",
|
"version": "8.13.3",
|
||||||
"resolved": "https://registry.npmjs.org/mermaid/-/mermaid-8.13.2.tgz",
|
"resolved": "https://registry.npmjs.org/mermaid/-/mermaid-8.13.3.tgz",
|
||||||
"integrity": "sha512-qTFI7MfC2d+x0Hft5gx063EH9tZg36lERG8o7Zq0Ag+MnO8CgVaMZEU6oA8gzTtTn9upMdy4UlYSLVmavu27cQ==",
|
"integrity": "sha512-w6KmDtSzkk856WUVqlBsyLZX0q4Jr35IlxiHTPTaWwMgWHFpI8rEJzcxWoyrpxeT/Rac/vvvSFOZymDTeA0iiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@braintree/sanitize-url": "^3.1.0",
|
"@braintree/sanitize-url": "^3.1.0",
|
||||||
"d3": "^7.0.0",
|
"d3": "^7.0.0",
|
||||||
"dagre": "^0.8.5",
|
"dagre": "^0.8.5",
|
||||||
"dagre-d3": "^0.6.4",
|
"dagre-d3": "^0.6.4",
|
||||||
"dompurify": "2.3.1",
|
"dompurify": "2.3.3",
|
||||||
"graphlib": "^2.1.8",
|
"graphlib": "^2.1.8",
|
||||||
"khroma": "^1.4.1",
|
"khroma": "^1.4.1",
|
||||||
"moment-mini": "^2.24.0",
|
"moment-mini": "^2.24.0",
|
||||||
|
|
Loading…
Reference in New Issue