0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-30 00:46:29 +01:00
svelte/sites/svelte.dev
Puru Vijay 5976de8f82
feat(site-2): Fully remove api.svelte.dev (#8432)
* Localize the examples dependents

* Localize FAQ

* Try to fix examples API

* Remove examples api

* Prerender, use vercel adapter, disable PUT action for now

* Don't call get_examples_data on top

* Move repl PUT to its own routew

* Don't prerender REPL page

* Change console warn

* Prerender tutorial the smart way

* Use getContext in root

* work around some weird content encoding glitch

* Try the pre-generate route

* Apply the suggestions

* Fix embed examples

* Remove comment

* remove commented-out code

* Update sites/svelte.dev/src/routes/_components/Demo.svelte

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>

* remove unused code

* add note to self, remove ts-ignore

* move adapter-vercel to devDependencies

* remove some unused deps

* huh we need flexsearch after all? weird

* we need sourcemap-codec as well — what the hell. are these deps missing from a dep?

---------

Co-authored-by: Rich Harris <git@rich-harris.dev>
Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
2023-04-02 10:35:10 -04:00
..
content/blog
scripts feat(site-2): Fully remove api.svelte.dev (#8432) 2023-04-02 10:35:10 -04:00
src feat(site-2): Fully remove api.svelte.dev (#8432) 2023-04-02 10:35:10 -04:00
static feat(site-2): Local examples (#8431) 2023-03-29 14:10:31 +02:00
.env feat(site-2): Fully remove api.svelte.dev (#8432) 2023-04-02 10:35:10 -04:00
.eslintrc.cjs
.gitignore feat(site-2): Fully remove api.svelte.dev (#8432) 2023-04-02 10:35:10 -04:00
.prettierrc feat(site-2): Local tutorial (#8427) 2023-03-29 14:07:21 +02:00
config.js
package-lock.json feat(site-2): Fully remove api.svelte.dev (#8432) 2023-04-02 10:35:10 -04:00
package.json feat(site-2): Fully remove api.svelte.dev (#8432) 2023-04-02 10:35:10 -04:00
README.md
svelte.config.js feat(site-2): Fully remove api.svelte.dev (#8432) 2023-04-02 10:35:10 -04:00
tsconfig.json
vite.config.js

Running locally

A local database is only required in dev mode if you want to test reading and writing saved REPLs on it. Without a local database in dev mode, the REPL will be able to load saved REPLs from the production database, but not save them.

Note also that in dev mode, the REPL will currently only work in Chrome, as noted in the Vite documentation, pending support in Firefox for import statements in web workers.

If you do want to use a database, set it up on Supabase with the instructions here and set the corresponding environment variables.

Run the site sub-project:

pnpm install
pnpm dev

and navigate to localhost:5173.

The first time you run the site locally, it will update the list of Contributors and REPL dependencies. After this it won't run again unless you force it by running:

pnpm update

Running using the local copy of Svelte

By default, the REPL will fetch the most recent version of Svelte from https://unpkg.com/svelte. When running the site locally, you can also use your local copy of Svelte.

To produce the proper browser-compatible UMD build of the compiler, you will need to run npm run build (or npm run dev) in the svelte repository with the PUBLISH environment variable set to any non-empty string:

git clone https://github.com/sveltejs/svelte.git
cd svelte
npm ci
PUBLISH=1 npm run build

The default configuration assumes that the sites repository and the svelte repository are in the same directory. If not, you can set LOCAL_SVELTE_PATH in sites/svelte.dev/.env to a different path to the local copy of Svelte.

Then visit the REPL at localhost:5173/repl?version=local. Please note that the local REPL only works with pnpm dev and not when building the site for production usage.

REPL GitHub integration

In order for the REPL's GitHub integration to work properly when running locally, you will need to:

  • create a GitHub OAuth app:
    • set Authorization callback URL to http://localhost:5173/auth/callback;
    • set Application name as you like, and Homepage URL as http://localhost:5173/;
    • create the app and take note of Client ID and Client Secret
  • in this directory, create an .env.local file (see .env.example) containing:
    GITHUB_CLIENT_ID=[your app's Client ID]
    GITHUB_CLIENT_SECRET=[your app's Client Secret]
    

The GitHub app requires a specific callback URL, and so cannot be used with the preview deployment in the staging environment.

Building the site

To build the website, run pnpm build. The output can be found in build.

Testing

Tests can be run using pnpm test.

Translating the API docs

Anchors are automatically generated using headings in the documentation and by default (for the english language) they are latinised to make sure the URL is always conforming to RFC3986.

If we need to translate the API documentation to a language using unicode chars, we can setup this app to export the correct anchors by setting up SLUG_PRESERVE_UNICODE to true in config.js.