Files
ECSESS/src/routes/r/[shortname]/+page.server.js
Antoine Phan 4f982e7ce3 Dynamic build and deployment on Vercel (#21)
* 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
2025-06-18 22:09:00 -04:00

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,
}
};