Skip to content

Commit

Permalink
Write to static to make index appear in public
Browse files Browse the repository at this point in the history
  • Loading branch information
Hysterelius committed Jul 6, 2024
1 parent b9ea658 commit 947dd77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package_abridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const replace = require('replace-in-file');
const util = require("util");
const { exec } = require("child_process");
const execPromise = util.promisify(exec);
const pagefind_index = require('./public/js/pagefind.index.js');
const pagefind_index = require('./static/js/pagefind.index.js');

if (!(fs.existsSync('config.toml'))) {
throw new Error('ERROR: cannot find config.toml!');
Expand Down
14 changes: 10 additions & 4 deletions static/js/pagefind.index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
async function createIndex() {
// Dynamically import the pagefind module
const pagefind = await import('pagefind');
const path = require('path');

// Import the path and fs modules to fetch the search index
const path = require('path');
const fs = require('fs');


Expand All @@ -12,7 +13,8 @@ async function createIndex() {
forceLanguage: 'en', // Force the language to English
});

const filePath = path.join(__dirname, '../search_index.en.json');

const filePath = path.join(__dirname, '../../public/search_index.en.json');

// Assuming fetch is available in the environment
// Fetch the data asynchronously and wait for the response
Expand All @@ -37,10 +39,14 @@ async function createIndex() {
}

// Write the index files to disk
await index.writeFiles({
outputPath: 'public/pagefind'
const {errors} = await index.writeFiles({
outputPath: './static/js/',
});

if (errors != []) {
console.log('Errors: ', errors);
}

console.log('Index created successfully!');
}

Expand Down

0 comments on commit 947dd77

Please sign in to comment.