Office Hour block, codebase clean up for schemas and utils
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getFromCMS } from 'utils/utils.js';
|
||||
import { getFromCMS } from '$lib/utils.js';
|
||||
import type { HomepageCMSResponse, OhCMSResponse } from '$lib/schemas';
|
||||
|
||||
const homepageQuery = `*[_type == "homepage"]{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getFromCMS } from 'utils/utils.js';
|
||||
import { getFromCMS } from '$lib/utils.js';
|
||||
|
||||
const query = `*[_type == "members"]{
|
||||
name,
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getFromCMS } from 'utils/utils.js';
|
||||
import { getFromCMS } from '$lib/utils.js';
|
||||
|
||||
// needs to concat and format this text
|
||||
const eventQuery = `*[_type == "events"]{
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
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,
|
||||
}
|
||||
};
|
||||
23
src/routes/r/[shortname]/+page.server.ts
Normal file
23
src/routes/r/[shortname]/+page.server.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { getFromCMS } from '$lib/utils.js';
|
||||
import type { Redirect } from '$lib/schemas';
|
||||
|
||||
const redirectQuery = `*[_type == "redirects"]{ shortname, url }`;
|
||||
|
||||
export const load = async ({ params }) => {
|
||||
let CMSresponse: Redirect[] = 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
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getFromCMS } from 'utils/utils.js';
|
||||
import { getFromCMS } from '$lib/utils.js';
|
||||
|
||||
// needs to concat and format this text
|
||||
const query = `*[_type == "resources"]{
|
||||
|
||||
Reference in New Issue
Block a user