Skip to content

Commit 2a612d0

Browse files
authored
Update dependencies (#105)
* Fix build by remove trailing slashes from Hugo relref URLs * Update dependencies * Update hugo * Remove lazysizes * Enable syntax highlighting * Remove KaTeX * Fix tabs * Remove instant.page * Remove clipboard * Fix postcss * Cleanup * Remove highlight.js * Fix navigation * Add files and changes from latest theme updates * Fix vulnerabilities * Fix sitemap * Fix copy of code * Lint JS * Fix command for markdown fixing * Improve index.html * Fix index.html from theme was loaded * Enable lead attribute again * Remove debug config * Fix docs repo url * Fix page was jumping to the middle on Firefox * Minor
1 parent 672dc5d commit 2a612d0

File tree

102 files changed

+5868
-3300
lines changed

Some content is hidden

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

102 files changed

+5868
-3300
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
assets/js/index.js
2-
assets/js/katex.js
32
assets/js/vendor
43
node_modules

.github/workflows/hugo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
build:
3232
runs-on: ubuntu-latest
3333
env:
34-
HUGO_VERSION: 0.128.0
34+
HUGO_VERSION: 0.148.1
3535
steps:
3636
- name: Install Hugo CLI
3737
run: |

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.env
2+
.netlify
3+
.hugo_build.lock
4+
node_modules
5+
public
6+
resources

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ The theme is a child-theme of [Doks](https://getdoks.org/docs/).
1111
The main theme is referenced as node_module and thus updating is handled via npm.
1212

1313
Following files have been overloaded and should be checked if they are changed on an update:
14-
- /layouts/partials/* (Removed integrity protection to run on Cloudflare CDN)
15-
- /layouts/index.headers (Removed CSP netlify)
16-
- /layouts/sitemap.xml (was not rendering without)
14+
15+
- `assets/js/flexsearch.js` (commented out one line due to an Firefox-related issue)
16+
- `/layouts/_default/single.html` (enable display of the `lead` attribute)
17+
- `/layouts/partials/*` (Removed integrity protection to run on Cloudflare CDN)
18+
- `/layouts/index.headers` (Removed CSP netlify)
1719

1820
## Local build
1921

assets/favicon.ico

15 KB
Binary file not shown.

assets/favicon.png

20.3 KB
Loading

assets/favicon.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/js/flexsearch.js

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*!
2+
* FlexSearch for Bootstrap based Thulite sites
3+
* Copyright 2021-2024 Thulite
4+
* Licensed under the MIT License
5+
* Based on https://github.com/frjo/hugo-theme-zen/blob/main/assets/js/search.js
6+
*/
7+
8+
/* eslint-disable no-undef, guard-for-in */
9+
10+
/**
11+
* @file
12+
* A JavaScript file for flexsearch.
13+
*/
14+
15+
// import * as FlexSearch from 'flexsearch';
16+
import Index from 'flexsearch';
17+
18+
(function () {
19+
20+
'use strict';
21+
22+
// const index = new FlexSearch.Document({
23+
const index = new Index.Document({
24+
tokenize: 'forward',
25+
document: {
26+
id: 'id',
27+
index: [
28+
{
29+
field: 'title'
30+
},
31+
{
32+
field: 'tags'
33+
},
34+
{
35+
field: {{ if site.Params.doks.indexSummary }}'summary'{{ else }}'content'{{ end }}
36+
},
37+
{
38+
field: 'date',
39+
tokenize: 'strict',
40+
encode: false
41+
}
42+
],
43+
store: ['title','summary','date','permalink']
44+
}
45+
});
46+
47+
function showResults(items) {
48+
const template = document.querySelector('template').content;
49+
const fragment = document.createDocumentFragment();
50+
51+
const results = document.querySelector('.search-results');
52+
results.textContent = '';
53+
54+
const itemsLength = Object.keys(items).length;
55+
56+
// Show/hide "No recent searches" and "No search results" messages
57+
if ((itemsLength === 0) && (query.value === '')) {
58+
// Hide "No search results" message
59+
document.querySelector('.search-no-results').classList.add('d-none');
60+
// Show "No recent searches" message
61+
document.querySelector('.search-no-recent').classList.remove('d-none');
62+
} else if ((itemsLength === 0) && (query.value !== '')) {
63+
// Hide "No recent searches" message
64+
document.querySelector('.search-no-recent').classList.add('d-none');
65+
// Show "No search results" message
66+
const queryNoResults = document.querySelector('.query-no-results');
67+
queryNoResults.innerText = query.value;
68+
document.querySelector('.search-no-results').classList.remove('d-none');
69+
} else {
70+
// Hide both "No recent searches" and "No search results" messages
71+
document.querySelector('.search-no-recent').classList.add('d-none');
72+
document.querySelector('.search-no-results').classList.add('d-none');
73+
}
74+
75+
for (const id in items) {
76+
const item = items[id];
77+
const result = template.cloneNode(true);
78+
const a = result.querySelector('a');
79+
const time = result.querySelector('time');
80+
const content = result.querySelector('.content');
81+
a.innerHTML = item.title;
82+
a.href = item.permalink;
83+
time.innerText = item.date;
84+
content.innerHTML = item.summary;
85+
fragment.appendChild(result);
86+
}
87+
88+
results.appendChild(fragment);
89+
}
90+
91+
function doSearch() {
92+
const query = document.querySelector('.search-text').value.trim();
93+
const limit = {{ .searchLimit }};
94+
const results = index.search({
95+
query: query,
96+
enrich: true,
97+
limit: limit,
98+
});
99+
const items = {};
100+
101+
results.forEach(function (result) {
102+
result.result.forEach(function (r) {
103+
items[r.id] = r.doc;
104+
});
105+
});
106+
107+
showResults(items);
108+
}
109+
110+
function enableUI() {
111+
const searchform = document.querySelector('.search-form');
112+
searchform.addEventListener('submit', function (e) {
113+
e.preventDefault();
114+
doSearch();
115+
});
116+
searchform.addEventListener('input', function () {
117+
doSearch();
118+
});
119+
document.querySelector('.search-loading').classList.add('d-none');
120+
document.querySelector('.search-input').classList.remove('d-none');
121+
122+
// Commented out the following line due to issue https://github.com/thuliteio/doks/discussions/1197
123+
// The focus on the search box still works without explicit action.
124+
// document.querySelector('.search-text').focus();
125+
}
126+
127+
function buildIndex() {
128+
document.querySelector('.search-loading').classList.remove('d-none');
129+
fetch("{{ site.LanguagePrefix }}/search-index.json")
130+
.then(function (response) {
131+
return response.json();
132+
})
133+
.then(function (data) {
134+
data.forEach(function (item) {
135+
index.add(item);
136+
});
137+
});
138+
}
139+
140+
buildIndex();
141+
enableUI();
142+
})();

assets/jsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"paths": {
5+
"*": ["*", "..\\node_modules\\@thulite\\doks-core\\assets\\*"]
6+
}
7+
}
8+
}

assets/mask-icon.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)