aboutsummaryrefslogtreecommitdiff
path: root/package_abridge.js
diff options
context:
space:
mode:
authorHysterelius2024-07-21 01:33:32 +1000
committerGitHub2024-07-20 08:33:32 -0700
commita7244a2983538f373c0af2ecfa4d6377584b8063 (patch)
treebc06b67d37ca88a5bbe938353f639cd28bef4d8d /package_abridge.js
parent4dab5b9538f76cd56f53e6a68f34f505234e30ed (diff)
downloadabridge-a7244a2983538f373c0af2ecfa4d6377584b8063.tar.gz
abridge-a7244a2983538f373c0af2ecfa4d6377584b8063.tar.bz2
abridge-a7244a2983538f373c0af2ecfa4d6377584b8063.zip
Add pagefind search to abridge (#179)
* Start process of adding pagefind to abridge * Write to static to make index appear in public * Add multilingual support * Minify files and fix running in script * Add pagefind files * Add loading of pagefind data * Update gitignore to remove pagefind index files * Get basic search result surfacing working * Remove duplicate entries in search results * Sanitise except to remove unnecessary details * Finalise addition of pagefind * Add missing await * Fix config.toml and remove old files on rebuild * Finish chores on pagefind addition
Diffstat (limited to 'package_abridge.js')
-rw-r--r--package_abridge.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/package_abridge.js b/package_abridge.js
index 137fccc..a15f3d3 100644
--- a/package_abridge.js
+++ b/package_abridge.js
@@ -115,6 +115,18 @@ async function abridge() {
replace.sync({files: 'content/static/tinysearch_json.md', from: /draft.*=.*/g, to: "draft = true"});
}
// zola build && stork build --input public/data_stork/index.html --output static/stork.st
+ } else if (search_library === 'pagefind') {
+ if (fs.existsSync('content/static/stork_toml.md')) {
+ replace.sync({files: 'content/static/stork_toml.md', from: /draft.*=.*/g, to: "draft = true"});
+ }
+ if (fs.existsSync('content/static/tinysearch_json.md')) {
+ replace.sync({files: 'content/static/tinysearch_json.md', from: /draft.*=.*/g, to: "draft = true"});
+ }
+
+ // Run the pagefind script to generate the index files.
+ // Has to happen at start otherwise, it happens too late asyncronously.
+ const createIndex = require('./static/js/pagefind.index.js'); // run the pagefind index.js script
+ await createIndex(); // makes program wait for pagefind build execution
}
if (pwa) {// Update pwa settings, file list, and hashes.
@@ -185,7 +197,7 @@ async function abridge() {
}
if (bpath === '') {// abridge used directly
- // These are truely static js files, so they should only need to be updated by abridge maintainer or contributors.
+ // These are truely static js files, so they should only need to be updated by the abridge maintainer or contributors.
minify(['static/js/theme.js']);
minify(['static/js/theme_light.js']);
minify(['static/js/katex.min.js','static/js/mathtex-script-type.min.js','static/js/katex-auto-render.min.js','static/js/katexoptions.js'],'static/js/katexbundle.min.js');
@@ -254,6 +266,9 @@ function bundle(bpath,js_prestyle,js_switcher,js_email_encode,js_copycode,search
minify_files.push(bpath+'static/js/stork_config.js');
} else if (search_library === 'tinysearch') {
minify_files.push(bpath+'static/js/tinysearch.js');
+ } else if (search_library === 'pagefind') {
+ minify_files.push(bpath+'static/js/pagefind.js');
+ minify_files.push(bpath+'static/js/pagefind.search.js');
}
}
if (pwa) {