Merge branch 'main' into node-adapter
This commit is contained in:
22
src/routes/r/[shortname]/+page.server.js
Normal file
22
src/routes/r/[shortname]/+page.server.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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,
|
||||
}
|
||||
};
|
||||
12
src/routes/r/[shortname]/+page.svelte
Normal file
12
src/routes/r/[shortname]/+page.svelte
Normal file
@@ -0,0 +1,12 @@
|
||||
<script>
|
||||
import Section from 'components/Section.svelte';
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Section>
|
||||
<p class="page-title">Where am I?</p>
|
||||
<p>
|
||||
Oops! We don't have a page for <code>"r/{data.shortname}"</code>.
|
||||
</p>
|
||||
<p>Please try again!</p>
|
||||
</Section>
|
||||
Reference in New Issue
Block a user