pull/8873/head
Puru Vijay 3 years ago
parent 7934a7f4d2
commit e9d7b9dd57

@ -521,7 +521,7 @@ Transitions are local by default (in Svelte 3, they were global by default). Loc
{/if}
```
> By default intro transitions will not play on first render. You can modify this behaviour by setting `intro: true` when you [create a component](/docs#run-time-client-side-component-api) and marking the transition as `global`.
> By default intro transitions will not play on first render. You can modify this behaviour by setting `intro: true` when you [create a component](/docs/client-side-component-api) and marking the transition as `global`.
## Transition parameters

@ -190,6 +190,9 @@ importers:
'@sveltejs/vite-plugin-svelte':
specifier: ^2.4.2
version: 2.4.2(svelte@packages+svelte)(vite@4.3.9)
'@types/cookie':
specifier: ^0.5.1
version: 0.5.1
'@types/marked':
specifier: ^5.0.0
version: 5.0.0

@ -32,6 +32,7 @@
"@sveltejs/kit": "^1.20.5",
"@sveltejs/site-kit": "6.0.0-next.18",
"@sveltejs/vite-plugin-svelte": "^2.4.2",
"@types/cookie": "^0.5.1",
"@types/marked": "^5.0.0",
"@types/node": "^20.3.1",
"@types/prettier": "^2.7.3",

@ -1,5 +1,11 @@
import * as session from '$lib/db/session';
/** @type {import('@sveltejs/adapter-vercel').Config} */
export const config = {
regions: ['pdx1', 'sfo1', 'cle1', 'iad1'],
runtime: 'edge'
};
export async function load({ request }) {
return {
user: session.from_cookie(request.headers.get('cookie'))

@ -2,7 +2,6 @@ import { dev } from '$app/environment';
import { client } from '$lib/db/client.js';
import * as gist from '$lib/db/gist.js';
import examples_data from '$lib/generated/examples-data.js';
import { get_example, get_examples_list } from '$lib/server/examples/index.js';
import { error, json } from '@sveltejs/kit';
export const prerender = 'auto';
@ -35,6 +34,7 @@ function munge(files) {
}
export async function GET({ params }) {
const { get_examples_list, get_example } = await import('$lib/server/examples/index.js');
// Currently, these pages(that are in examples/) are prerendered. To avoid making any FS requests,
// We prerender examples pages during build time. That means, when something like `/repl/hello-world.json`
// is accessed, this function won't be run at all, as it will be served from the filesystem
@ -95,6 +95,8 @@ export async function GET({ params }) {
}
export async function entries() {
const { get_examples_list } = await import('$lib/server/examples/index.js');
return get_examples_list(examples_data)
.map(({ examples }) => examples)
.flatMap((val) => val.map(({ slug }) => ({ id: slug })));

@ -1,6 +1,5 @@
import { uneval } from 'devalue';
import * as cookie from 'cookie';
import { stringify } from 'querystring';
import * as session from '$lib/db/session';
import { oauth, client_id, client_secret } from '../_config.js';
@ -9,11 +8,11 @@ export async function GET({ url }) {
// Trade "code" for "access_token"
const r1 = await fetch(
`${oauth}/access_token?` +
stringify({
new URLSearchParams({
code: url.searchParams.get('code'),
client_id,
client_secret
})
}).toString()
);
const access_token = new URLSearchParams(await r1.text()).get('access_token');

@ -1,16 +1,15 @@
import { stringify } from 'querystring';
import { redirect } from '@sveltejs/kit';
import { oauth, client_id } from '../_config.js';
import { client_id, oauth } from '../_config.js';
export const GET = client_id
? ({ url }) => {
const Location =
`${oauth}/authorize?` +
stringify({
new URLSearchParams({
scope: 'read:user',
client_id,
redirect_uri: `${url.origin}/auth/callback`
});
}).toString();
throw redirect(302, Location);
}

@ -7,7 +7,6 @@ import {
replaceExportTypePlaceholders
} from '@sveltejs/site-kit/markdown';
import fs from 'node:fs';
import path from 'node:path';
import glob from 'tiny-glob/sync.js';
import { CONTENT_BASE } from '../../constants.js';
@ -18,6 +17,11 @@ function get_href(parts) {
return parts.length > 1 ? `/docs/${parts[0]}#${parts.at(-1)}` : `/docs/${parts[0]}`;
}
/** @param {string} path */
function path_basename(path) {
return path.split(/[\\/]/).pop();
}
export function content() {
/** @type {import('@sveltejs/site-kit/search').Block[]} */
const blocks = [];
@ -25,7 +29,7 @@ export function content() {
const breadcrumbs = [];
for (const file of glob('**/*.md', { cwd: `${base}/docs` })) {
const basename = path.basename(file);
const basename = path_basename(file);
const match = /\d{2}-(.+)\.md/.exec(basename);
if (!match) continue;

@ -1,9 +1,17 @@
import { get_docs_data, get_docs_list } from '$lib/server/docs/index.js';
export const prerender = true;
export function load({ url }) {
export async function load({ url }) {
const is_docs_index = url.pathname === '/docs';
if (!is_docs_index) {
const { get_docs_data, get_docs_list } = await import('$lib/server/docs/index.js');
return {
sections: url.pathname === '/docs' ? [] : get_docs_list(get_docs_data())
};
}
return {
sections: url.pathname === '/docs' ? [] : get_docs_list(get_docs_data())
sections: []
};
}

@ -1,2 +1,2 @@
// This page now exists solely for redirect, prerendering triggers the `handleMissingID`
export const prerender = false;
export const prerender = true;

@ -1,10 +1,9 @@
import { get_example, get_examples_data, get_examples_list } from '$lib/server/examples/index.js';
import { get_example, get_examples_list } from '$lib/server/examples/index.js';
import examples_data from '$lib/generated/examples-data.js';
export const prerender = true;
export async function load({ params }) {
const examples_data = get_examples_data();
const examples_list = get_examples_list(examples_data);
const example = get_example(examples_data, params.slug);

@ -1,6 +1,7 @@
import { get_blog_data, get_blog_list } from '$lib/server/blog/index.js';
import { get_docs_data, get_docs_list } from '$lib/server/docs/index.js';
import { get_examples_data, get_examples_list } from '$lib/server/examples/index.js';
import { get_examples_list } from '$lib/server/examples/index.js';
import examples_data from '$lib/generated/examples-data.js';
import { json } from '@sveltejs/kit';
export const prerender = true;
@ -32,7 +33,7 @@ async function get_nav_list() {
}
];
const examples_list = get_examples_list(get_examples_data());
const examples_list = get_examples_list(examples_data);
const processed_examples_list = examples_list
.map(({ title, examples }) => ({
title,

@ -4,7 +4,7 @@ import adapter from '@sveltejs/adapter-vercel';
/** @type {import('@sveltejs/kit').Config} */
export default {
kit: {
adapter: adapter()
adapter: adapter({ runtime: 'edge', split: true })
},
vitePlugin: {

Loading…
Cancel
Save