mirror of
https://github.com/revanced/revanced-website.git
synced 2025-05-02 07:34:34 +02:00
afn will explod
This commit is contained in:
parent
81033b3f29
commit
24af6f54e4
@ -1,82 +0,0 @@
|
|||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
// This code was stolen from https://github.com/sveltejs/kit/blob/master/packages/adapter-static/platforms.js
|
|
||||||
|
|
||||||
// sveltekit does things like this instead of actually just using ts for some reason.
|
|
||||||
/** @param {import('@sveltejs/kit').Builder} builder */
|
|
||||||
function vercel_routes(builder) {
|
|
||||||
/** @type {any[]} */
|
|
||||||
const routes = [
|
|
||||||
{
|
|
||||||
src: `/${builder.config.kit.appDir}/immutable/.+`,
|
|
||||||
headers: {
|
|
||||||
'cache-control': 'public, immutable, max-age=31536000'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
// explicit redirects
|
|
||||||
for (const [src, redirect] of builder.prerendered.redirects) {
|
|
||||||
routes.push({
|
|
||||||
src,
|
|
||||||
headers: {
|
|
||||||
Location: redirect.location
|
|
||||||
},
|
|
||||||
status: redirect.status
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// prerendered pages
|
|
||||||
for (const [src, page] of builder.prerendered.pages) {
|
|
||||||
routes.push({
|
|
||||||
src,
|
|
||||||
dest: `${builder.config.kit.appDir}/prerendered/${page.file}`
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// implicit redirects (trailing slashes)
|
|
||||||
for (const [src] of builder.prerendered.pages) {
|
|
||||||
if (src !== '/') {
|
|
||||||
routes.push({
|
|
||||||
src: src.endsWith('/') ? src.slice(0, -1) : src + '/',
|
|
||||||
headers: {
|
|
||||||
location: src
|
|
||||||
},
|
|
||||||
status: 308
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
routes.push({
|
|
||||||
handle: 'filesystem'
|
|
||||||
});
|
|
||||||
|
|
||||||
return routes;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function wrap(adapter, opts) {
|
|
||||||
if (!process.env.VERCEL) {
|
|
||||||
// we don't have to bother :)
|
|
||||||
return adapter(opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not exactly what adapter-static does, but it works.
|
|
||||||
opts.pages = '.vercel/output/static';
|
|
||||||
|
|
||||||
adapter = adapter(opts);
|
|
||||||
|
|
||||||
const adapt_fn = adapter.adapt;
|
|
||||||
adapter.adapt = async (builder) => {
|
|
||||||
const result = await adapt_fn(builder);
|
|
||||||
fs.writeFileSync(
|
|
||||||
'.vercel/output/config.json',
|
|
||||||
JSON.stringify({
|
|
||||||
version: 3,
|
|
||||||
routes: vercel_routes(builder)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return adapter;
|
|
||||||
}
|
|
1
src/routes/+layout.ts
Normal file
1
src/routes/+layout.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const prerender = true;
|
@ -1,8 +1,6 @@
|
|||||||
import adapter from '@sveltejs/adapter-static';
|
import adapter from '@sveltejs/adapter-static';
|
||||||
import preprocess from 'svelte-preprocess';
|
import preprocess from 'svelte-preprocess';
|
||||||
|
|
||||||
import { wrap } from './src/_vercel-moment.js';
|
|
||||||
|
|
||||||
/** @type {import('@sveltejs/kit').Config} */
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
// Consult https://github.com/sveltejs/svelte-preprocess
|
// Consult https://github.com/sveltejs/svelte-preprocess
|
||||||
@ -12,9 +10,9 @@ const config = {
|
|||||||
kit: {
|
kit: {
|
||||||
// adapter-static has vercel detection, but that does not let you set a custom 404 page easily.
|
// adapter-static has vercel detection, but that does not let you set a custom 404 page easily.
|
||||||
// Instead, we have to use a wrapper that generates a vercel config if on vercel...
|
// Instead, we have to use a wrapper that generates a vercel config if on vercel...
|
||||||
adapter: wrap(adapter, {
|
adapter: adapter({
|
||||||
pages: "public",
|
pages: 'public',
|
||||||
fallback: "404.html"
|
fallback: '404.html'
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user