2023-11-08 23:30:56 +00:00
import { PUBLIC_SITE_URL } from '$env/static/public' ;
2023-12-15 23:13:59 +00:00
import type { Album } from '$lib/types/album' ;
import type { ArticlePageLoad } from '$lib/types/article' ;
2024-12-02 03:14:16 +00:00
import { fetchBandcampAlbums } from '$lib/util/fetchBandcampAlbums' ;
import type { MetaTagsProps } from 'svelte-meta-tags' ;
import type { PageServerLoad } from './$types' ;
2023-02-14 06:54:54 +00:00
2023-11-08 20:28:18 +00:00
export const load : PageServerLoad = async ( { fetch , setHeaders , url } ) = > {
2024-05-30 19:03:03 +00:00
let baseUrl ;
2023-12-09 01:04:31 +00:00
if ( url . origin . includes ( 'prerender' ) ) {
baseUrl = PUBLIC_SITE_URL || 'https://bradleyshellnut.com' ;
} else {
baseUrl = new URL ( url . origin ) . href || PUBLIC_SITE_URL || 'https://bradleyshellnut.com' ;
}
2023-11-08 23:30:56 +00:00
const currentPageUrl = new URL ( url . pathname , url . origin ) . href ;
2023-11-08 20:28:18 +00:00
const metaTags : MetaTagsProps = Object . freeze ( {
title : 'Home' ,
2023-11-08 21:04:23 +00:00
description : "My name is Bradley Shellnut and I'm a Full Stack Software Engineer." ,
2023-11-08 20:28:18 +00:00
openGraph : {
title : 'Home' ,
2023-11-08 21:04:23 +00:00
description : "My name is Bradley Shellnut and I'm a Full Stack Software Engineer." ,
2023-11-08 23:30:56 +00:00
url : currentPageUrl ,
2023-11-08 20:28:18 +00:00
siteName : 'Bradley Shellnut Personal Website' ,
2023-11-08 21:50:44 +00:00
type : 'website' ,
locale : 'en_US' ,
images : [
{
2023-12-09 00:08:14 +00:00
url : ` ${ baseUrl } og?header=Home | bradleyshellnut.com&page=Hi I'm Bradley Shellnut.&content=I'm a full stack software engineer currently working on Java Spring, PostgreSQL, and React / Angular JS. ` ,
2023-12-09 00:02:30 +00:00
alt : 'Bradley Shellnut Website Home Page' ,
width : 1200 ,
height : 630
2023-11-08 21:50:44 +00:00
}
]
2023-11-08 20:28:18 +00:00
} ,
twitter : {
title : 'Home' ,
description : 'Home page' ,
2023-11-08 21:50:44 +00:00
card : 'summary_large_image' ,
2023-12-09 00:08:14 +00:00
image : ` ${ baseUrl } og?header=Home | bradleyshellnut.com&page=Hi I'm Bradley Shellnut.&content=I'm a full stack software engineer currently working on Java Spring, PostgreSQL, and React / Angular JS. ` ,
2023-11-08 21:50:44 +00:00
imageAlt : 'Bradley Shellnut Website Logo'
2023-11-08 20:28:18 +00:00
} ,
2023-11-08 23:30:56 +00:00
url : currentPageUrl
2023-11-08 20:28:18 +00:00
} ) ;
2024-12-03 17:35:23 +00:00
// const [albums, articles]: [Album[], ArticlePageLoad] = await Promise.all([
// await fetchBandcampAlbums(),
// (await fetch('/api/articles?page=1&limit=3')).json()
// ]);
2023-12-15 19:03:46 +00:00
2023-02-14 06:54:54 +00:00
setHeaders ( {
'cache-control' : 'max-age=43200'
} ) ;
return {
2023-11-08 21:29:04 +00:00
baseUrl ,
2023-11-08 20:28:18 +00:00
metaTagsChild : metaTags ,
2024-12-03 17:35:23 +00:00
albums : await fetchBandcampAlbums ( ) ,
articlesData : await ( await fetch ( '/api/articles?page=1&limit=3' ) ) . json ( )
2023-02-14 06:54:54 +00:00
} ;
2023-11-08 23:30:56 +00:00
} ;