svelte-adapter-ghpages
Version:
SvelteKit adapter for gh-pages
88 lines (63 loc) • 3.19 kB
Markdown
# svelte-adapter-ghpages
SvelteKit adapter for gh-pages
| :warning: WARNING: this project is considered to be in BETA until SvelteKit is available for general use and the Adapter API is stable! |
| --------------------------------------------------------------------------------------------------------------------------------------- |
[](https://www.npmjs.com/package/svelte-adapter-ghpages)
[](https://www.npmjs.com/package/svelte-adapter-ghpages)
[](http://www.npmtrends.com/svelte-adapter-ghpages)
[](http://www.npmtrends.com/svelte-adapter-ghpages)
[](http://www.npmtrends.com/svelte-adapter-ghpages)
[](http://www.npmtrends.com/svelte-adapter-ghpages)
[](http://www.npmtrends.com/svelte-adapter-ghpages)
[](https://github.com/ota-meshi/svelte-adapter-ghpages/actions?query=workflow%3ACI)
[](https://coveralls.io/github/ota-meshi/svelte-adapter-ghpages?branch=main)
## 📛 Features
This is an adapter for the [SvelteKit].
This adapter will generate `404.html` in addition to the files generated by [@sveltejs/adapter-static] to work well with GitHub Pages.
## 💿 Installation
```bash
npm install --save-dev svelte-adapter-ghpages
```
## 📖 Usage
Add it to `svelte.config.js`
```js
// svelte.config.js
import adapterGhpages from "svelte-adapter-ghpages";
/** @type {import('@sveltejs/kit').Config} */
const config = {
// ...
kit: {
// ...
paths: {
base: "/your-repo-name",
},
// ...
adapter: adapterGhpages(
// default options are shown
pages: 'build',
assets: 'build',
fallback: null
),
// ...
},
};
```
Add `404.svelte` to the routes directory.
For example: `src/routes/404.svelte`
```svelte
<h1>404</h1>
<blockquote>
<p>Not Found</p>
</blockquote>
```
`404.svelte` will be placed as `404.html` when you run `npm run build`.
[sveltekit]: https://kit.svelte.dev/
[@sveltejs/adapter-static]: https://github.com/sveltejs/kit/tree/master/packages/adapter-static
### Options
#### `pages`, `assets`, `fallback`
See [https://github.com/sveltejs/kit/tree/master/packages/adapter-static#pages](https://github.com/sveltejs/kit/tree/master/packages/adapter-static#pages).
## :beers: Contributing
Welcome contributing!
Please use GitHub's Issues/PRs.
## :lock: License
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).