Office Hour block, codebase clean up for schemas and utils

This commit is contained in:
Antoine Phan
2025-07-19 12:32:47 -04:00
parent fe3495227d
commit e0a4aa1fa8
11 changed files with 57 additions and 67 deletions

View File

@@ -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"]{

View File

@@ -1,4 +1,4 @@
import { getFromCMS } from 'utils/utils.js';
import { getFromCMS } from '$lib/utils.js';
const query = `*[_type == "members"]{
name,

View File

@@ -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"]{

View File

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

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

View File

@@ -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"]{