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
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
assets/js/index.js
assets/js/katex.js
assets/js/vendor
node_modules
2 changes: 1 addition & 1 deletion .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.128.0
HUGO_VERSION: 0.148.1
steps:
- name: Install Hugo CLI
run: |
Expand Down
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.env
.netlify
.hugo_build.lock
node_modules
public
resources
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ The theme is a child-theme of [Doks](https://getdoks.org/docs/).
The main theme is referenced as node_module and thus updating is handled via npm.

Following files have been overloaded and should be checked if they are changed on an update:
- /layouts/partials/* (Removed integrity protection to run on Cloudflare CDN)
- /layouts/index.headers (Removed CSP netlify)
- /layouts/sitemap.xml (was not rendering without)

- `assets/js/flexsearch.js` (commented out one line due to an Firefox-related issue)
- `/layouts/_default/single.html` (enable display of the `lead` attribute)
- `/layouts/partials/*` (Removed integrity protection to run on Cloudflare CDN)
- `/layouts/index.headers` (Removed CSP netlify)

## Local build

Expand Down
Binary file added assets/favicon.ico
Binary file not shown.
Binary file added assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 142 additions & 0 deletions assets/js/flexsearch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*!
* FlexSearch for Bootstrap based Thulite sites
* Copyright 2021-2024 Thulite
* Licensed under the MIT License
* Based on https://github.com/frjo/hugo-theme-zen/blob/main/assets/js/search.js
*/

/* eslint-disable no-undef, guard-for-in */

/**
* @file
* A JavaScript file for flexsearch.
*/

// import * as FlexSearch from 'flexsearch';
import Index from 'flexsearch';

(function () {

'use strict';

// const index = new FlexSearch.Document({
const index = new Index.Document({
tokenize: 'forward',
document: {
id: 'id',
index: [
{
field: 'title'
},
{
field: 'tags'
},
{
field: {{ if site.Params.doks.indexSummary }}'summary'{{ else }}'content'{{ end }}
},
{
field: 'date',
tokenize: 'strict',
encode: false
}
],
store: ['title','summary','date','permalink']
}
});

function showResults(items) {
const template = document.querySelector('template').content;
const fragment = document.createDocumentFragment();

const results = document.querySelector('.search-results');
results.textContent = '';

const itemsLength = Object.keys(items).length;

// Show/hide "No recent searches" and "No search results" messages
if ((itemsLength === 0) && (query.value === '')) {
// Hide "No search results" message
document.querySelector('.search-no-results').classList.add('d-none');
// Show "No recent searches" message
document.querySelector('.search-no-recent').classList.remove('d-none');
} else if ((itemsLength === 0) && (query.value !== '')) {
// Hide "No recent searches" message
document.querySelector('.search-no-recent').classList.add('d-none');
// Show "No search results" message
const queryNoResults = document.querySelector('.query-no-results');
queryNoResults.innerText = query.value;
document.querySelector('.search-no-results').classList.remove('d-none');
} else {
// Hide both "No recent searches" and "No search results" messages
document.querySelector('.search-no-recent').classList.add('d-none');
document.querySelector('.search-no-results').classList.add('d-none');
}

for (const id in items) {
const item = items[id];
const result = template.cloneNode(true);
const a = result.querySelector('a');
const time = result.querySelector('time');
const content = result.querySelector('.content');
a.innerHTML = item.title;
a.href = item.permalink;
time.innerText = item.date;
content.innerHTML = item.summary;
fragment.appendChild(result);
}

results.appendChild(fragment);
}

function doSearch() {
const query = document.querySelector('.search-text').value.trim();
const limit = {{ .searchLimit }};
const results = index.search({
query: query,
enrich: true,
limit: limit,
});
const items = {};

results.forEach(function (result) {
result.result.forEach(function (r) {
items[r.id] = r.doc;
});
});

showResults(items);
}

function enableUI() {
const searchform = document.querySelector('.search-form');
searchform.addEventListener('submit', function (e) {
e.preventDefault();
doSearch();
});
searchform.addEventListener('input', function () {
doSearch();
});
document.querySelector('.search-loading').classList.add('d-none');
document.querySelector('.search-input').classList.remove('d-none');

// Commented out the following line due to issue https://github.com/thuliteio/doks/discussions/1197
// The focus on the search box still works without explicit action.
// document.querySelector('.search-text').focus();
}

function buildIndex() {
document.querySelector('.search-loading').classList.remove('d-none');
fetch("{{ site.LanguagePrefix }}/search-index.json")
.then(function (response) {
return response.json();
})
.then(function (data) {
data.forEach(function (item) {
index.add(item);
});
});
}

buildIndex();
enableUI();
})();
8 changes: 8 additions & 0 deletions assets/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["*", "..\\node_modules\\@thulite\\doks-core\\assets\\*"]
}
}
}
1 change: 1 addition & 0 deletions assets/mask-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 14 additions & 10 deletions assets/scss/app.scss
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
// Source: https://getbootstrap.com/docs/5.3/customize/sass/#importing

/** Import Bootstrap functions */
@import "bootstrap/scss/functions";

/** Import theme variables */
@import "common/variables";
@import "common/colors";
@import "common/variables-overrides";
@import "common/variables-custom";

/** Import Bootstrap */
@import "bootstrap/scss/bootstrap";

/** Import highlight.js */
// @import "highlight.js/scss/github-dark-dimmed";

/** Import KaTeX */
@import "katex/dist/katex";
@import "../../node_modules/bootstrap/scss/bootstrap";

/** Import theme styles */
@import "common/fonts";
@import "common/global";
@import "common/syntax";
@import "common/dark";
@import "components/alerts";
@import "components/buttons";
@import "components/callouts";
@import "components/expressive-code";
@import "components/code";
@import "components/details";
@import "components/syntax";
@import "components/comments";
@import "components/details";
@import "components/forms";
@import "components/images";
@import "components/mermaid";
@import "components/modals";
@import "components/search";
@import "components/section-nav";
@import "components/steps";
@import "components/tables";
@import "components/tabs";
@import "layouts/footer";
@import "layouts/header";
@import "layouts/pages";
Expand Down
1 change: 1 addition & 0 deletions assets/scss/common/_variables-custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** Custom variables */
17 changes: 0 additions & 17 deletions babel.config.js

This file was deleted.

119 changes: 0 additions & 119 deletions config/_default/config.toml

This file was deleted.

Loading