Skip to content

Commit 3d320c0

Browse files
committed
deploy: a69212a
1 parent 52a3e3e commit 3d320c0

2,192 files changed

Lines changed: 88936 additions & 20154 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

404.html

Lines changed: 84 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<meta property="og:description" content="Page Not Found">
1111
<meta property="og:title" content="jMonkeyEngine Docs">
1212
<link rel="stylesheet" href="/_/css/site-extra.css">
13-
<link rel="stylesheet" href="/_pagefind/pagefind-ui.css">
1413
<link rel="icon" href="/_/img/favicon.ico" type="image/x-icon">
1514
</head>
1615
<body class="status-404">
@@ -113,22 +112,90 @@ <h1 class="page">Page Not Found</h1>
113112
<p>Copyright 2020 jMonkeyEngine Wiki Contributors. Licensed BSD-3.</p>
114113
</footer>
115114
<span hidden data-pagefind-filter="version:"></span>
116-
<script src="/_pagefind/pagefind-ui.js"></script>
117-
<script>
118-
new window.PagefindUI({
119-
element: '#search',
120-
showImages: false,
121-
showEmptyFilters: false,
122-
resetStyles: false,
123-
filters: {
124-
version: [''],
125-
},
126-
pagefind_options: {
127-
filters: {
128-
version: [''],
129-
},
130-
},
131-
});
115+
<script type="module">
116+
const currentVersion = '';
117+
const expectedPath = `/docs/${currentVersion}/`;
118+
const root = document.querySelector('#search');
119+
120+
if (!root) {
121+
console.error('Search root not found');
122+
} else {
123+
root.innerHTML = `
124+
<input type="search" class="wiki-search-input" placeholder="Search docs" aria-label="Search docs" />
125+
<div class="wiki-search-results" hidden></div>
126+
`;
127+
128+
const input = root.querySelector('.wiki-search-input');
129+
const panel = root.querySelector('.wiki-search-results');
130+
131+
const pagefind = await import('/_pagefind/pagefind.js');
132+
133+
function clearResults() {
134+
panel.innerHTML = '';
135+
panel.hidden = true;
136+
}
137+
138+
function renderItems(items) {
139+
if (!items.length) {
140+
panel.innerHTML = '<p class="wiki-search-empty">No results in this version.</p>';
141+
panel.hidden = false;
142+
return;
143+
}
144+
145+
const html = items
146+
.map((item) => `
147+
<article class="wiki-search-item">
148+
<a class="wiki-search-link" href="${item.url}">${item.meta?.title || item.url}</a>
149+
<p class="wiki-search-excerpt">${item.excerpt || ''}</p>
150+
</article>
151+
`)
152+
.join('');
153+
154+
panel.innerHTML = html;
155+
panel.hidden = false;
156+
}
157+
158+
async function search(term) {
159+
const query = term.trim();
160+
if (!query) {
161+
clearResults();
162+
return;
163+
}
164+
165+
const response = await pagefind.search(query, {
166+
filters: {
167+
version: currentVersion,
168+
},
169+
});
170+
171+
const loaded = await Promise.all(response.results.slice(0, 20).map((r) => r.data()));
172+
const strict = loaded.filter((item) => {
173+
try {
174+
return new URL(item.url, window.location.origin).pathname.includes(expectedPath);
175+
} catch (e) {
176+
return (item.url || '').includes(expectedPath);
177+
}
178+
});
179+
180+
renderItems(strict.slice(0, 8));
181+
}
182+
183+
let timer;
184+
input.addEventListener('input', () => {
185+
clearTimeout(timer);
186+
timer = setTimeout(() => {
187+
search(input.value).catch((err) => {
188+
console.error('Search failed', err);
189+
panel.innerHTML = '<p class="wiki-search-empty">Search unavailable.</p>';
190+
panel.hidden = false;
191+
});
192+
}, 160);
193+
});
194+
195+
document.addEventListener('click', (event) => {
196+
if (!root.contains(event.target)) clearResults();
197+
});
198+
}
132199
</script>
133200
<script src="/_/js/site.js"></script>
134201
<script async src="/_/js/vendor/highlight.js"></script>

_/css/site-extra.css

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,19 @@
3434
position: relative;
3535
}
3636

37-
#search .pagefind-ui__search-input {
37+
#search .wiki-search-input {
3838
color: #333;
3939
font-family: inherit;
4040
font-size: 0.95rem;
4141
width: 100%;
4242
border: 1px solid #dbdbdb;
43-
border-radius: 0.1em;
43+
border-radius: 3px;
4444
line-height: 1.5;
45-
padding: 0 0.25em;
46-
}
47-
48-
#search .pagefind-ui__form {
49-
position: relative;
50-
}
51-
52-
#search .pagefind-ui__form::before {
53-
display: none;
45+
padding: 0.25rem 0.4rem;
46+
background: #fff;
5447
}
5548

56-
#search .pagefind-ui__drawer {
49+
#search .wiki-search-results {
5750
position: absolute;
5851
top: 100%;
5952
right: 0;
@@ -67,44 +60,47 @@
6760
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
6861
z-index: 1000;
6962
padding: 0.5rem 1rem;
63+
margin-top: 0.25rem;
7064
}
7165

72-
#search .pagefind-ui__result-link {
73-
color: #1a0dab;
74-
text-decoration: none;
66+
#search .wiki-search-item {
67+
padding: 0.45rem 0;
68+
border-top: 1px solid #efefef;
7569
}
7670

77-
#search .pagefind-ui__result-link:hover {
78-
text-decoration: underline;
71+
#search .wiki-search-item:first-child {
72+
border-top: 0;
7973
}
8074

81-
#search .pagefind-ui__result-excerpt {
82-
color: #333;
83-
}
84-
85-
#search .pagefind-ui__message {
86-
color: #555;
75+
#search .wiki-search-link {
76+
color: #1a0dab;
77+
text-decoration: none;
78+
font-size: 0.95rem;
79+
font-weight: 600;
8780
}
8881

89-
#search .pagefind-ui__button {
90-
color: #333;
91-
background: #fff;
82+
#search .wiki-search-link:hover {
83+
text-decoration: underline;
9284
}
9385

94-
#search .pagefind-ui__search-clear {
86+
#search .wiki-search-excerpt {
9587
color: #333;
96-
background: #fff;
88+
margin: 0.2rem 0 0;
89+
font-size: 0.85rem;
90+
line-height: 1.35;
9791
}
9892

99-
#search .pagefind-ui__filter-panel {
100-
display: none;
93+
#search .wiki-search-empty {
94+
color: #555;
95+
margin: 0;
96+
padding: 0.25rem 0;
10197
}
10298

10399
@media screen and (max-width: 768px) {
104100
#search {
105101
width: 100px;
106102
}
107-
#search .pagefind-ui__drawer {
103+
#search .wiki-search-results {
108104
width: 300px;
109105
right: -50px;
110106
}
-1.96 KB
Binary file not shown.
-2.7 KB
Binary file not shown.
-2.82 KB
Binary file not shown.
-3.52 KB
Binary file not shown.
-1.66 KB
Binary file not shown.
-996 Bytes
Binary file not shown.
-3.72 KB
Binary file not shown.
-1.13 KB
Binary file not shown.

0 commit comments

Comments
 (0)