Skip to content

Commit

Permalink
Merge pull request #37 from Hugos68/feat/v1
Browse files Browse the repository at this point in the history
Rewrite, basically
  • Loading branch information
Hugos68 authored May 25, 2024
2 parents b76439c + 010e977 commit 19e58d2
Show file tree
Hide file tree
Showing 14 changed files with 1,901 additions and 1,900 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-rules-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vite-plugin-pagefind": minor
---

Added `dev_strategy` option, meaning you can develop with eager or lazy indexing
5 changes: 5 additions & 0 deletions .changeset/wild-grapes-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vite-plugin-pagefind": minor
---

Plugin now strictly uses pagefind.json
78 changes: 39 additions & 39 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,195 +4,195 @@

### Patch Changes

- c6b6c63: bugfix: Types are now exported from root index
- c6b6c63: bugfix: Types are now exported from root index

## 0.1.0

### Minor Changes

- bc84506: Feature: Added type definitions importable from `vite-plugin-pagefind/types`
- bc84506: Breaking: Renamed `PagefindPluginConfig` to `Config`
- bc84506: Breaking: Named `publicDir` to `assetsDir`
- bc84506: Feature: Added type definitions importable from `vite-plugin-pagefind/types`
- bc84506: Breaking: Renamed `PagefindPluginConfig` to `Config`
- bc84506: Breaking: Named `publicDir` to `assetsDir`

### Patch Changes

- bc84506: bugfix: replaced `process.cwd()` with `config.root` to conform with Vite
- bc84506: bugfix: replaced `process.cwd()` with `config.root` to conform with Vite

## 0.0.30

### Patch Changes

- 3bd4c12: Add quotes to path so it still works when there are spaces in the path
- 3bd4c12: Add quotes to path so it still works when there are spaces in the path

## 0.0.29

### Patch Changes

- f085992: Added nuxt example
- f085992: Added nuxt example

## 0.0.28

### Patch Changes

- e02e88b: Fixed dynamic import broken only on initial dev server
- e02e88b: Fixed dynamic import broken only on initial dev server

## 0.0.27

### Patch Changes

- a10bad1: Fixed bad directory
- a10bad1: Fixed bad directory

## 0.0.26

### Patch Changes

- f1427a7: Cleaned up some internals
- f1427a7: Cleaned up some internals

## 0.0.25

### Patch Changes

- 19ca67b: Fixed executeMeasured return time (start - stop should be stop - start)
- 19ca67b: Fixed executeMeasured return time (start - stop should be stop - start)

## 0.0.24

### Patch Changes

- 720dbb8: Removed the automatic pagefind run on post build in favor of manually doing so to be framework agnostic (some frameworks have their own CLI wrappers around Vite so it was impossible to run post build since the framework ran after `vite build` had completed.
- 720dbb8: Removed the automatic pagefind run on post build in favor of manually doing so to be framework agnostic (some frameworks have their own CLI wrappers around Vite so it was impossible to run post build since the framework ran after `vite build` had completed.

## 0.0.23

### Patch Changes

- d8de3ba: Graph improvements
- d8de3ba: Graph improvements

## 0.0.22

### Patch Changes

- 7aafe6b: Added flow chart to showcase what pagefind does
- 7aafe6b: Added flow chart to showcase what pagefind does

## 0.0.21

### Patch Changes

- 74aed9c: Added Astro example :tada:
- 74aed9c: Added Astro example :tada:

## 0.0.20

### Patch Changes

- ce7ba7a: Docs cleanup and default empty object fix
- ce7ba7a: Docs cleanup and default empty object fix

## 0.0.19

### Patch Changes

- 396c975: Added @antfu/ni in order to detect package and allow for more flexible build process (rather than harcoding `vite build`
- 396c975: Added @antfu/ni in order to detect package and allow for more flexible build process (rather than harcoding `vite build`

## 0.0.18

### Patch Changes

- 6da3d09: Minor doc changes
- 6da3d09: Minor doc changes

## 0.0.17

### Patch Changes

- dfde5a4: Added examples folder, added SvelteKit
- dfde5a4: Added examples folder, added SvelteKit

## 0.0.16

### Patch Changes

- e1cbe1f: Fixed dynamic imports being due to faulty vite configuration
- e1cbe1f: Fixed dynamic imports being due to faulty vite configuration

## 0.0.15

### Patch Changes

- 6bb27bc: Fixed nested pagefind dir
- 6bb27bc: Fixed nested pagefind dir

## 0.0.14

### Patch Changes

- 3759d12: Removed testing console.log
- 3759d12: Removed testing console.log

## 0.0.13

### Patch Changes

- a9d0e41: Removed prerequisites from docs since the plugin will handle pagefind through the node API
- a9d0e41: Removed prerequisites from docs since the plugin will handle pagefind through the node API

## 0.0.12

### Patch Changes

- e08ff34: Cleaned up docs, renamed appDir to publicDir (makes more sense with vite), added LICENSE
- b974483: Fixed docs
- e08ff34: Cleaned up docs, renamed appDir to publicDir (makes more sense with vite), added LICENSE
- b974483: Fixed docs

## 0.0.11

### Patch Changes

- 692518a: Added assetsInclude config and external config to make usage of pagefind FAR easier
- 692518a: Added assetsInclude config and external config to make usage of pagefind FAR easier

## 0.0.10

### Patch Changes

- cf9d8a7: Forced buildDir to be present
- 9f91f77: Fixed buildDir being optional type
- cf9d8a7: Forced buildDir to be present
- 9f91f77: Fixed buildDir being optional type

## 0.0.9

### Patch Changes

- 1dc1751: Renamed pagefindDir to appDir and removed the need to specify the `pagefind` folder
- 1dc1751: Added documentation (see README.md)
- 1dc1751: Renamed pagefindDir to appDir and removed the need to specify the `pagefind` folder
- 1dc1751: Added documentation (see README.md)

## 0.0.8

### Patch Changes

- bd97d3d: Finally fixed running pagefind after build
- fcf32c0: Fixed broken vite dependency: https://github.com/vitejs/vite/issues/15714
- bd97d3d: Finally fixed running pagefind after build
- fcf32c0: Fixed broken vite dependency: https://github.com/vitejs/vite/issues/15714

## 0.0.7

### Patch Changes

- 9bdcc49: Fixed pagefind post build not running after the build process
- 9bdcc49: Fixed pagefind post build not running after the build process

## 0.0.6

### Patch Changes

- d911925: Fixed hardcoded buildDir
- 324852e: Added quotes around paths for pagefind to prevent invalid paths from occuring
- d911925: Fixed hardcoded buildDir
- 324852e: Added quotes around paths for pagefind to prevent invalid paths from occuring

## 0.0.5

### Patch Changes

- 04163e9: Added cwd option that defaults to process.cwd, added default to buildDir: build
- 04163e9: Added cwd option that defaults to process.cwd, added default to buildDir: build

## 0.0.4

### Patch Changes

- 93731cd: Bugfix: Had colorette as devDep causing issues with the plugin
- 93731cd: Bugfix: Had colorette as devDep causing issues with the plugin

## 0.0.3

### Patch Changes

- 2f8a075: Only packaging dist files now
- 2f8a075: Only packaging dist files now

## 0.0.2

### Patch Changes

- a969687: Released package
- a969687: Released package
54 changes: 22 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ pnpm add -D pagefind vite-plugin-pagefind

```ts
import { defineConfig } from 'vite';
import { pagefind, type Config } from 'vite-plugin-pagefind';

const config: Config = {
assetsDir: '...',
buildDir: '...',
buildScript: '...'
};
import pagefind from 'vite-plugin-pagefind';

export default defineConfig({
plugins: [pagefind(config)]
plugins: [pagefind()]
});
```

Expand All @@ -45,36 +39,40 @@ Note: If your framework does not have a `vite.config` checkout the [examples](#e
```json
{
"scripts": {
"build": "vite build && pagefind --site <BUILD_DIR>"
"build": "vite build && pagefind"
}
}
```

Note: Replace `<BUILD_DIR>` with your build directory.
3. Add the `pagefind.json` config to your project:

```json
{
"site": "<BUILD_DIR>",
"vite_plugin": {
"assets_dir": "<ASSETS_DIR>",
"build_command": "BUILD_COMMAND",
"dev_strategy": "DEV_STRATEGY"
}
}
```

## Config

### assetsDir
### assets_dir

The directory where the static assets are located relative to the project's root as specified in the vite config.

Example: `assetsDir: 'public'` results in: `public/pagefind/pagefind.js`

_default:_ 'public'
### dev_strategy

### buildDir
The indexing strategy used during development:

The directory where the build output is located relative to the project's root as specified in the vite config.
- "eager": Build and index the app every time the development server starts
- "lazy": Build and index the app only if the pagefind bundle isn't present already

Example: `buildDir: 'dist'` results in: `dist/pagefind/pagefind.js`
### build_command

_default:_ 'dist'

### buildScript

The npm script to run to build and index the project.

_default:_ 'build'
The command to build and index the project.

## Examples

Expand All @@ -86,14 +84,6 @@ The setup for individual frameworks can differ (For example Astro, which has it'

Don't see your framework? Consider adding it through a contribution!

## Types

Besides the plugin, this package also exposes [the types from pagefind](https://github.com/CloudCannon/pagefind/blob/production-docs/pagefind_web_js/types/index.d.ts) as well as extending them by providing an additional `Pagefind` type:

```ts
const pagefind: Pagefind = await import('/pagefind/pagefind.js');
```

## Pagefind

For further questions regarding Pagefind itself you can refer to [the offical docs](https://pagefind.app/).
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"vite": "^5.0.12"
},
"dependencies": {
"@antfu/ni": "^0.21.12",
"colorette": "^2.0.20"
"colorette": "^2.0.20",
"valibot": "0.31.0-rc.4"
},
"type": "module",
"keywords": [
Expand Down
Loading

0 comments on commit 19e58d2

Please sign in to comment.