Skip to content

Commit f8cf1fe

Browse files
Make site work on IPFS (#9539)
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
1 parent 2a9a946 commit f8cf1fe

File tree

18 files changed

+35
-25
lines changed

18 files changed

+35
-25
lines changed

documentation/docs/10-getting-started/20-creating-a-project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ npm install
1111
npm run dev
1212
```
1313

14-
The first command will scaffold a new project in the `my-app` directory asking you if you'd like to set up some basic tooling such as TypeScript. See the FAQ for [pointers on setting up additional tooling](/faq#integrations). The subsequent commands will then install its dependencies and start a server on [localhost:5173](http://localhost:5173).
14+
The first command will scaffold a new project in the `my-app` directory asking you if you'd like to set up some basic tooling such as TypeScript. See the FAQ for [pointers on setting up additional tooling](../faq#integrations). The subsequent commands will then install its dependencies and start a server on [localhost:5173](http://localhost:5173).
1515

1616
There are two basic concepts:
1717

documentation/docs/10-getting-started/30-project-structure.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ The `src` directory contains the meat of your project. Everything except `src/ro
4646
- `%sveltekit.body%` — the markup for a rendered page. This should live inside a `<div>` or other element, rather than directly inside `<body>`, to prevent bugs caused by browser extensions injecting elements that are then destroyed by the hydration process. SvelteKit will warn you in development if this is not the case
4747
- `%sveltekit.assets%` — either [`paths.assets`](configuration#paths), if specified, or a relative path to [`paths.base`](configuration#paths)
4848
- `%sveltekit.nonce%` — a [CSP](configuration#csp) nonce for manually included links and scripts, if used
49-
- `%sveltekit.env.[NAME]%` - this will be replaced at render time with the `[NAME]` environment variable, which must begin with the [`publicPrefix`](https://kit.svelte.dev/docs/configuration#env) (usually `PUBLIC_`). It will fallback to `''` if not matched.
49+
- `%sveltekit.env.[NAME]%` - this will be replaced at render time with the `[NAME]` environment variable, which must begin with the [`publicPrefix`](configuration#env) (usually `PUBLIC_`). It will fallback to `''` if not matched.
5050
- `error.html` is the page that is rendered when everything else fails. It can contain the following placeholders:
5151
- `%sveltekit.status%` — the HTTP status
5252
- `%sveltekit.error.message%` — the error message
53-
- `hooks.client.js` contains your client [hooks](/docs/hooks)
54-
- `hooks.server.js` contains your server [hooks](/docs/hooks)
55-
- `service-worker.js` contains your [service worker](/docs/service-workers)
53+
- `hooks.client.js` contains your client [hooks](hooks)
54+
- `hooks.server.js` contains your server [hooks](hooks)
55+
- `service-worker.js` contains your [service worker](service-workers)
5656

5757
(Whether the project contains `.js` or `.ts` files depends on whether you opt to use TypeScript when you create your project. You can switch between JavaScript and TypeScript in the documentation using the toggle at the bottom of this page.)
5858

documentation/docs/20-core-concepts/40-page-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ This option also affects [prerendering](#prerender). If `trailingSlash` is `alwa
157157
158158
## config
159159

160-
With the concept of [adapters](/docs/adapters), SvelteKit is able to run on a variety of platforms. Each of these might have specific configuration to further tweak the deployment — for example on Vercel you could choose to deploy some parts of your app on the edge and others on serverless environments.
160+
With the concept of [adapters](adapters), SvelteKit is able to run on a variety of platforms. Each of these might have specific configuration to further tweak the deployment — for example on Vercel you could choose to deploy some parts of your app on the edge and others on serverless environments.
161161

162162
`config` is an object with key-value pairs at the top level. Beyond that, the concrete shape is dependent on the adapter you're using. Every adapter should provide a `Config` interface to import for type safety. Consult the documentation of your adapter for more information.
163163

documentation/docs/20-core-concepts/50-state-management.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const actions = {
3636

3737
The `user` variable is shared by everyone who connects to this server. If Alice submitted an embarrassing secret, and Bob visited the page after her, Bob would know Alice's secret. In addition, when Alice returns to the site later in the day, the server may have restarted, losing her data.
3838

39-
Instead, you should _authenticate_ the user using [`cookies`](/docs/load#cookies-and-headers) and persist the data to a database.
39+
Instead, you should _authenticate_ the user using [`cookies`](load#cookies-and-headers) and persist the data to a database.
4040

4141
## No side-effects in load
4242

@@ -75,13 +75,13 @@ export async function load({ fetch }) {
7575
}
7676
```
7777

78-
...and pass it around to the components that need it, or use [`$page.data`](/docs/load#$page-data).
78+
...and pass it around to the components that need it, or use [`$page.data`](load#$page-data).
7979

8080
If you're not using SSR, then there's no risk of accidentally exposing one user's data to another. But you should still avoid side-effects in your `load` functions — your application will be much easier to reason about without them.
8181

8282
## Using stores with context
8383

84-
You might wonder how we're able to use `$page.data` and other [app stores](/docs/modules#$app-stores) if we can't use our own stores. The answer is that app stores on the server use Svelte's [context API](https://learn.svelte.dev/tutorial/context-api) — the store is attached to the component tree with `setContext`, and when you subscribe you retrieve it with `getContext`. We can do the same thing with our own stores:
84+
You might wonder how we're able to use `$page.data` and other [app stores](modules#$app-stores) if we can't use our own stores. The answer is that app stores on the server use Svelte's [context API](https://learn.svelte.dev/tutorial/context-api) — the store is attached to the component tree with `setContext`, and when you subscribe you retrieve it with `getContext`. We can do the same thing with our own stores:
8585

8686
```svelte
8787
/// file: src/routes/+layout.svelte
@@ -167,4 +167,4 @@ If you have state that should survive a reload and/or affect SSR, such as filter
167167

168168
## Storing ephemeral state in snapshots
169169

170-
Some UI state, such as 'is the accordion open?', is disposable — if the user navigates away or refreshes the page, it doesn't matter if the state is lost. In some cases, you _do_ want the data to persist if the user navigates to a different page and comes back, but storing the state in the URL or in a database would be overkill. For this, SvelteKit provides [snapshots](/docs/snapshots), which let you associate component state with a history entry.
170+
Some UI state, such as 'is the accordion open?', is disposable — if the user navigates away or refreshes the page, it doesn't matter if the state is lost. In some cases, you _do_ want the data to persist if the user navigates to a different page and comes back, but storing the state in the URL or in a database would be overkill. For this, SvelteKit provides [snapshots](snapshots), which let you associate component state with a history entry.

documentation/docs/25-build-and-deploy/50-adapter-static.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default {
2222
// these options are set automatically — see below
2323
pages: 'build',
2424
assets: 'build',
25-
fallback: null,
25+
fallback: undefined,
2626
precompress: false,
2727
strict: true
2828
})

documentation/docs/25-build-and-deploy/70-adapter-cloudflare-workers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export {};
114114

115115
### Worker size limits
116116

117-
When deploying to workers, the server generated by SvelteKit is bundled into a single file. Wrangler will fail to publish your worker if it exceeds [the size limits](https://developers.cloudflare.com/workers/platform/limits/#worker-size) after minification. You're unlikely to hit this limit usually, but some large libraries can cause this to happen. In that case, you can try to reduce the size of your worker by only importing such libraries on the client side. See [the FAQ](/faq#how-do-i-use-a-client-side-only-library-that-depends-on-document-or-window) for more information.
117+
When deploying to workers, the server generated by SvelteKit is bundled into a single file. Wrangler will fail to publish your worker if it exceeds [the size limits](https://developers.cloudflare.com/workers/platform/limits/#worker-size) after minification. You're unlikely to hit this limit usually, but some large libraries can cause this to happen. In that case, you can try to reduce the size of your worker by only importing such libraries on the client side. See [the FAQ](../faq#how-do-i-use-a-client-side-only-library-that-depends-on-document-or-window) for more information.
118118

119119
### Accessing the file system
120120

documentation/docs/25-build-and-deploy/90-adapter-vercel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default {
2626

2727
## Deployment configuration
2828

29-
To control how your routes are deployed to Vercel as functions, you can specify deployment configuration, either through the option shown above or with [`export const config`](/docs/page-options#config) inside `+server.js`, `+page(.server).js` and `+layout(.server).js` files.
29+
To control how your routes are deployed to Vercel as functions, you can specify deployment configuration, either through the option shown above or with [`export const config`](page-options#config) inside `+server.js`, `+page(.server).js` and `+layout(.server).js` files.
3030

3131
For example you could deploy some parts of your app as [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions)...
3232

documentation/docs/30-advanced/30-link-options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In SvelteKit, `<a>` elements (rather than framework-specific `<Link>` components
66

77
You can customise the behaviour of links with `data-sveltekit-*` attributes. These can be applied to the `<a>` itself, or to a parent element.
88

9-
These options also apply to `<form>` elements with [`method="GET"`](/docs/form-actions#get-vs-post).
9+
These options also apply to `<form>` elements with [`method="GET"`](form-actions#get-vs-post).
1010

1111
## data-sveltekit-preload-data
1212

@@ -80,7 +80,7 @@ Sometimes you don't want navigation to create a new entry in the browser's sessi
8080

8181
## data-sveltekit-keepfocus
8282

83-
Sometimes you don't want [focus to be reset](/docs/accessibility#focus-management) after navigation. For example, maybe you have a search form that submits as the user is typing, and you want to keep focus on the text input. Adding a `data-sveltekit-keepfocus` attribute to it...
83+
Sometimes you don't want [focus to be reset](accessibility#focus-management) after navigation. For example, maybe you have a search form that submits as the user is typing, and you want to keep focus on the text input. Adding a `data-sveltekit-keepfocus` attribute to it...
8484

8585
```html
8686
<form data-sveltekit-keepfocus>

documentation/docs/30-advanced/70-packaging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ You can read more about that feature [here](https://www.typescriptlang.org/docs/
160160

161161
You should avoid using [SvelteKit-specific modules](modules) like `$app` in your packages unless you intend for them to only be consumable by other SvelteKit projects. E.g. rather than using `import { browser } from '$app/environment'` you could use `import { BROWSER } from 'esm-env'` ([see esm-env docs](https://github.com/benmccann/esm-env)). You may also wish to pass in things like the current URL or a navigation action as a prop rather than relying directly on `$app/stores`, `$app/navigation`, etc. Writing your app in this more generic fashion will also make it easier to setup tools for testing, UI demos and so on.
162162

163-
Ensure that you add [aliases](/docs/configuration#alias) via `svelte.config.js` (not `vite.config.js` or `tsconfig.json`), so that they are processed by `svelte-package`.
163+
Ensure that you add [aliases](configuration#alias) via `svelte.config.js` (not `vite.config.js` or `tsconfig.json`), so that they are processed by `svelte-package`.
164164

165165
You should think carefully about whether or not the changes you make to your package are a bug fix, a new feature, or a breaking change, and update the package version accordingly. Note that if you remove any paths from `exports` or any `export` conditions inside them from your existing library, that should be regarded as a breaking change.
166166

documentation/docs/60-appendix/05-integrations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ You will need to install `svelte-preprocess` with `npm install --save-dev svelte
3131

3232
## Integration FAQs
3333

34-
The SvelteKit FAQ has a [section on integrations](/faq#integrations), which may be helpful if you still have questions.
34+
The SvelteKit FAQ has a [section on integrations](../faq#integrations), which may be helpful if you still have questions.

documentation/docs/60-appendix/10-migrating.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ This file has no equivalent in SvelteKit. Any custom logic (beyond `sapper.start
4949

5050
### src/server.js
5151

52-
When using `adapter-node` the equivalent is a [custom server](/docs/adapter-node#custom-server). Otherwise, this file has no direct equivalent, since SvelteKit apps can run in serverless environments.
52+
When using `adapter-node` the equivalent is a [custom server](adapter-node#custom-server). Otherwise, this file has no direct equivalent, since SvelteKit apps can run in serverless environments.
5353

5454
### src/service-worker.js
5555

@@ -146,7 +146,7 @@ To support this environment-agnostic behavior, `fetch` is now available in the g
146146

147147
## Integrations
148148

149-
See [the FAQ](/faq#integrations) for detailed information about integrations.
149+
See [the FAQ](../faq#integrations) for detailed information about integrations.
150150

151151
### HTML minifier
152152

documentation/docs/60-appendix/20-additional-resources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Additional resources
44

55
## FAQs
66

7-
Please see the [SvelteKit FAQ](/faq) for solutions to common issues and helpful tips and tricks.
7+
Please see the [SvelteKit FAQ](../faq) for solutions to common issues and helpful tips and tricks.
88

99
The [Svelte FAQ](https://svelte.dev/faq) and [`vite-plugin-svelte` FAQ](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md) may also be helpful for questions deriving from those libraries.
1010

sites/kit.svelte.dev/scripts/check-doc-links.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ for (const doc of doc_filenames) {
5454
const [path] = url.split('#');
5555
if (path === 'modules' || path === 'types' || path === 'configuration') continue; // autogenerated docs
5656

57+
if (path === '../faq') continue;
58+
5759
if (!doc_urls.has(url)) {
5860
bad = true;
5961
console.error(`Bad link: ${url} in ${doc}`);
@@ -73,6 +75,8 @@ for (const file of walk_kit_dir(path.join(__dirname, '../../../packages/kit')))
7375
const [path] = link.split('#');
7476
if (path === 'modules' || path === 'types' || path === 'configuration') continue; // autogenerated docs
7577

78+
if (path.startsWith('../faq')) continue;
79+
7680
if (!doc_urls.has(link)) {
7781
bad = true;
7882
console.error(`Bad link: ${link} in ${file}`);

sites/kit.svelte.dev/src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="color-scheme" content="dark light" />
88

99
<link rel="manifest" href="/manifest.json" />
10-
<link rel="icon" type="image/png" href="/favicon.png" />
10+
<link rel="icon" type="image/png" href="%sveltekit.assets%/favicon.png" />
1111

1212
<meta name="twitter:card" content="summary" />
1313
<meta name="twitter:site" content="@sveltejs" />

sites/kit.svelte.dev/src/lib/docs/Contents.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import { base } from '$app/paths';
23
import { page } from '$app/stores';
34
45
export let contents = [];
@@ -19,7 +20,7 @@
1920
data-sveltekit-preload-data
2021
class="page"
2122
class:active={path === $page.url.pathname}
22-
href={path}
23+
href="{base}{path}"
2324
>
2425
{title}
2526
</a>

sites/kit.svelte.dev/src/routes/docs/+page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import { base } from '$app/paths';
33

44
/** @type {import('./$types').Load} */
55
export function load() {
6-
throw redirect(307, `${base}/docs/introduction`);
6+
throw redirect(307, `./docs/introduction`);
77
}

sites/kit.svelte.dev/src/routes/home/Deployment.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import lambda from './logos/lambda.svg';
1111
import azure from './logos/azure.svg';
1212
import plus from '$lib/icons/plus.svg';
13+
import { base } from '$app/paths';
1314
</script>
1415

1516
<Section --background="var(--background-1)">
@@ -111,7 +112,7 @@
111112

112113
<div class="globe">
113114
<img
114-
src="/edge.svg?{$theme.current}"
115+
src="{base}/edge.svg?{$theme.current}"
115116
width="100%"
116117
height="100%"
117118
alt="Dynamically rendered map of the world, centered on the user's location"

sites/kit.svelte.dev/svelte.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ const config = {
55
kit: {
66
adapter: adapter({
77
runtime: 'edge'
8-
})
8+
}),
9+
10+
paths: {
11+
relative: true
12+
}
913
},
1014

1115
vitePlugin: {

0 commit comments

Comments
 (0)