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
30 changes: 30 additions & 0 deletions src/partials/search-scripts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script src="{{{uiRootPath}}}/js/vendor/lunr.js" defer></script>
{{#if env.SITE_SEARCH_LANGUAGES}}
<script src="{{{uiRootPath}}}/js/vendor/lunr-languages.js" defer></script>
{{/if}}
<script src="https://cdn.jsdelivr.net/pako/1.0.3/pako.min.js" defer></script>
<script src="{{{uiRootPath}}}/js/search-ui.js" id="search-ui-script" data-site-root-path="{{{siteRootPath}}}" data-snippet-length="100" data-stylesheet="{{{uiRootPath}}}/css/search.css" defer></script>
<script>
window.addEventListener('DOMContentLoaded', function(){
try {
var script = document.getElementById('search-ui-script');
var siteRoot = (script && script.getAttribute('data-site-root-path')) || '';
var manifestUrl = siteRoot + '/search-index/manifest.json';
fetch(manifestUrl)
.then(function (r) { return r.ok ? r.json() : Promise.reject(new Error('manifest not found')) })
.then(function (manifest) { antoraSearch.bootstrap(lunr, manifest, siteRoot); })
.catch(function () {
var s = document.createElement('script');
s.async = true;
s.src = siteRoot + '/search-index.js';
document.head.appendChild(s);
});
} catch (e) {
// Fallback to monolithic index if anything goes wrong
var s = document.createElement('script');
s.async = true;
s.src = '{{{siteRootPath}}}/search-index.js';
document.head.appendChild(s);
}
});
</script>
145 changes: 145 additions & 0 deletions src/static/css/search.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
.search-result-dropdown-menu {
position: absolute;
z-index: 100;
display: block;
right: 0;
left: inherit;
top: 100%;
border-radius: 4px;
margin: 6px 0 0;
padding: 0;
text-align: left;
height: auto;
background: transparent;
border: none;
max-width: 600px;
min-width: 500px;
box-shadow: 0 1px 0 0 rgb(0 0 0 / 20%), 0 2px 3px 0 rgb(0 0 0 / 10%);
}

@media screen and (width<= 768px) {
.search-result-dropdown-menu {
min-width: calc(100vw - 3.75rem);
}
}

.search-result-dataset {
position: relative;
border: 1px solid #d9d9d9;
background: #fff;
border-radius: 4px;
overflow: auto;
padding: 8px;
max-height: calc(100vh - 5.25rem);
line-height: 1.5;
}

.search-result-item {
display: flex;
margin-top: 0.5rem;
}

.search-result-component-header {
color: #1e1e1e;
border-bottom: 1px solid #ddd;
margin-left: 0.5em;
margin-right: 0.5em;
padding-top: 0.25em;
padding-bottom: 0.25em;
}

.search-result-document-title {
width: 33%;
border-right: 1px solid #ddd;
color: #02060c;
font-weight: 500;
font-size: 0.8rem;
padding: 0.5rem 0.5rem 0.5rem 0;
text-align: right;
position: relative;
word-wrap: break-word;
}

.search-result-document-hit {
flex: 1;
font-size: 0.75rem;
color: #63676d;
}

.search-result-document-hit > a {
color: inherit;
display: block;
padding: 0.55rem 0.25rem 0.55rem 0.75rem;
}

.search-result-document-hit > a:hover {
background-color: rgb(69 142 225 / 5%);
}

.search-result-document-hit .search-result-highlight {
color: #174d8c;
background: rgb(143 187 237 / 10%);
padding: 0.1em 0.05em;
font-weight: 500;
}

.search-result-document-hit .search-result-section-title {
color: #303030;
font-weight: 500;
font-size: 1.05em;
margin-bottom: 0.25em;
}

.search-result-document-hit .search-result-keywords {
margin-top: 0.25em;
}

.search-result-document-hit .search-result-keywords-field-label {
font-weight: bold;
}

#search-input {
padding: 0.25em;
}

#search-input:disabled {
cursor: not-allowed;
opacity: 0.6;
}

.search-result-loading-notice {
padding: 0.5rem 0.75rem;
font-size: 0.85rem;
color: #666;
font-style: italic;
border-bottom: 1px solid #eee;
margin-bottom: 0.25rem;
}

#search-input:focus {
outline: none;
}

#search-field {
display: flex;
}

#search-field .filter {
background: #fff linear-gradient(180deg, #e1e1e1 0, #e1e1e1) no-repeat 0/1px 50%;
border: 1px solid #e1e1e1;
border-left: none;
border-radius: 0 0.1em 0.1em 0;
color: #5d5d5d;
cursor: pointer;
font-size: 0.875em;
display: flex;
align-items: center;
padding: 0 0.5rem;
white-space: nowrap;
overflow: hidden;
}

#search-field.has-filter > input {
border-right: none;
border-radius: 0.1em 0 0 0.1em;
}
Loading