* Make deployment doable on EUS and Vercel servers * Revert to adapter-auto for now * Remove `r/` layout file * Fixing deployment configuration and landing page for redirects * Clean up PR
24 lines
589 B
JavaScript
24 lines
589 B
JavaScript
import { redirect } from '@sveltejs/kit';
|
|
import { getFromCMS } from 'utils/utils.js';
|
|
|
|
const redirectQuery = `*[_type == "redirects"]{ shortname, url }`;
|
|
|
|
export const load = async ({ params }) => {
|
|
/** @type {[{shortname: String, url: String}]} */
|
|
let CMSresponse = await getFromCMS(redirectQuery);
|
|
|
|
const { shortname } = params;
|
|
|
|
CMSresponse.forEach(res => {
|
|
if(res.shortname == shortname) {
|
|
// if match
|
|
throw redirect(302, res.url);
|
|
}
|
|
});
|
|
|
|
return {
|
|
shortname: shortname,
|
|
availableShortnames: CMSresponse,
|
|
}
|
|
};
|