Skip to content

Commit

Permalink
Renamed pagefind_url to pagefind_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
hankertrix committed Nov 22, 2024
1 parent de5e6f8 commit 5e932b1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 3 additions & 3 deletions src/internal/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}),
{},
Expand All @@ -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,
"",
);
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/pagefind-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
],
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/pagefind-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
],
},
},
Expand Down

0 comments on commit 5e932b1

Please sign in to comment.