diff --git a/README.md b/README.md index 777b4ef..d8a0d1b 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,9 @@ The command to build and index the project. _default_: 'npm run build' -### pagefind_url +### pagefind_dir -The URL you use to import the pagefind script on your site. For example, if you use `/pagefind/pagefind.js`, the `pagefind_url` is `pagefind`. If you use `/search/static/pagefind/pagefind.js`, the `pagefind_url` is `search/static/pagefind` +The URL directory you use to import the pagefind script on your site. For example, if you use `/pagefind/pagefind.js`, the `pagefind_dir` is `pagefind`. If you use `/search/static/pagefind/pagefind.js`, the `pagefind_dir` is `search/static/pagefind`. _default_: 'pagefind' diff --git a/src/internal/config.js b/src/internal/config.js index 733327f..ae4494d 100644 --- a/src/internal/config.js +++ b/src/internal/config.js @@ -8,7 +8,7 @@ const PagefindConfigSchema = v.object({ v.object({ assets_dir: v.optional(v.string(), "public"), build_command: v.optional(v.string(), "npm run build"), - pagefind_url: v.optional(v.string(), "pagefind"), + pagefind_dir: v.optional(v.string(), "pagefind"), dev_strategy: v.optional(v.picklist(["eager", "lazy"]), "lazy"), }), {}, @@ -27,8 +27,8 @@ export async function get_pagefind_config(cwd) { ); const pagefind_parsed = JSON.parse(pagefind_raw); const config = v.parse(PagefindConfigSchema, pagefind_parsed); - const pagefind_url = config.vite_plugin_pagefind.pagefind_url; - config.vite_plugin_pagefind.pagefind_url = pagefind_url.replace( + const pagefind_dir = config.vite_plugin_pagefind.pagefind_dir; + config.vite_plugin_pagefind.pagefind_dir = pagefind_dir.replace( /^\/+|\/+$/g, "", ); diff --git a/src/plugins/pagefind-build.js b/src/plugins/pagefind-build.js index a21d7e0..aebc6f5 100644 --- a/src/plugins/pagefind-build.js +++ b/src/plugins/pagefind-build.js @@ -12,13 +12,13 @@ export default function build() { async config() { const cwd = process.cwd(); const pagefind_config = await get_pagefind_config(cwd); - const pagefind_url = pagefind_config.vite_plugin_pagefind.pagefind_url; + const pagefind_dir = pagefind_config.vite_plugin_pagefind.pagefind_dir; return { build: { rollupOptions: { external: [ - `/${pagefind_url}/pagefind.js`, - `/${pagefind_url}/pagefind-highlight.js`, + `/${pagefind_dir}/pagefind.js`, + `/${pagefind_dir}/pagefind-highlight.js`, ], }, }, diff --git a/src/plugins/pagefind-dev.js b/src/plugins/pagefind-dev.js index 398f88b..0322f4f 100644 --- a/src/plugins/pagefind-dev.js +++ b/src/plugins/pagefind-dev.js @@ -20,14 +20,14 @@ export default function dev() { async config() { const cwd = process.cwd(); const pagefind_config = await get_pagefind_config(cwd); - const pagefind_url = pagefind_config.vite_plugin_pagefind.pagefind_url; + const pagefind_dir = pagefind_config.vite_plugin_pagefind.pagefind_dir; return { assetsInclude: ["**/pagefind.js", "**/pagefind-highlight.js"], build: { rollupOptions: { external: [ - `/${pagefind_url}/pagefind.js`, - `/${pagefind_url}/pagefind-highlight.js`, + `/${pagefind_dir}/pagefind.js`, + `/${pagefind_dir}/pagefind-highlight.js`, ], }, },