Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/search/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const server = http.createServer((req, res) => {
if (!document.foundHeaderId && document.headersMap[id].toLocaleLowerCase().indexOf(searchQuery.toLocaleLowerCase()) > -1) {
document.foundHeaderId = id;
document.isExactMatch = document.headersMap[id].toLocaleLowerCase().trim() == searchQuery.toLocaleLowerCase().trim();
document.uri += `#${id}`;
// 'top' is the internal id for the page title, so don't append in uri
document.uri += id === 'top' ? '' : `#${id}`;
document.title = document.headersMap[id];
}
});
Expand Down
2 changes: 1 addition & 1 deletion themes/docs/layouts/partials/contentPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ partial "breadcrumbs" . }}
<div class="article">
<div class="article_title">
<h1 id="top">
<h1>
{{.Title}}
</h1>
{{ if .File }}
Expand Down
3 changes: 2 additions & 1 deletion themes/docs/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ document.addEventListener("DOMContentLoaded", function () {
const anchors = document.querySelectorAll(".article h1, .article h2, .article h3, .article h4");
anchors.forEach(function (el) {
let url = new URL(window.location.href);
el.insertAdjacentHTML('beforeend', '<a class="anchor" href="' + url.origin + url.pathname + '#' + el.id + '"><i class="bi bi-link-45deg"></i></a>');
const hash = el.id ? `#${el.id}` : '';
el.insertAdjacentHTML('beforeend', '<a class="anchor" href="' + url.origin + url.pathname + hash + '"><i class="bi bi-link-45deg"></i></a>');
});

document.querySelectorAll('a.anchor').forEach(function (a) {
Expand Down
Loading