diff --git a/src/app.html b/src/app.html index be94b35..6474910 100644 --- a/src/app.html +++ b/src/app.html @@ -2,10 +2,6 @@ - diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 527fb47..801b62f 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,23 +1,28 @@ import type { MetaTagsProps } from 'svelte-meta-tags'; -import type { PageServerLoad } from './lib/$types'; -import { fetchBandcampAlbums } from '$root/lib/util/fetchBandcampAlbums'; +import { PUBLIC_SITE_URL } from '$env/static/public'; +import type { PageServerLoad } from './$types'; +import { fetchBandcampAlbums } from '$lib/util/fetchBandcampAlbums'; export const load: PageServerLoad = async ({ fetch, setHeaders, url }) => { - const baseUrl = new URL(url.origin).href; + const baseUrl = new URL(url.origin).href || PUBLIC_SITE_URL || 'https://bradleyshellnut.com'; + const currentPageUrl = new URL(url.pathname, url.origin).href; + const metaTags: MetaTagsProps = Object.freeze({ title: 'Home', description: "My name is Bradley Shellnut and I'm a Full Stack Software Engineer.", openGraph: { title: 'Home', description: "My name is Bradley Shellnut and I'm a Full Stack Software Engineer.", - url: new URL(url.pathname, url.origin).href, + url: currentPageUrl, siteName: 'Bradley Shellnut Personal Website', type: 'website', locale: 'en_US', images: [ { url: `${baseUrl}b_shell_nut_favicon.gif`, - alt: 'Bradley Shellnut Website Logo' + alt: 'Bradley Shellnut Website Logo', + width: 512, + height: 512 } ] }, @@ -28,7 +33,7 @@ export const load: PageServerLoad = async ({ fetch, setHeaders, url }) => { image: `${baseUrl}b_shell_nut_favicon.gif`, imageAlt: 'Bradley Shellnut Website Logo' }, - url: new URL(url.pathname, url.origin).href + url: currentPageUrl }); const albums = async () => await fetchBandcampAlbums(); @@ -43,5 +48,4 @@ export const load: PageServerLoad = async ({ fetch, setHeaders, url }) => { albums: albums(), articlesData: (await articles()).json() }; -}; -// ; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/routes/about/+page.ts b/src/routes/about/+page.ts index 9cd3f11..a721ccd 100644 --- a/src/routes/about/+page.ts +++ b/src/routes/about/+page.ts @@ -1,17 +1,39 @@ export const prerender = true; import type { MetaTagsProps } from 'svelte-meta-tags'; +import { PUBLIC_SITE_URL } from '$env/static/public'; import type { PageLoad } from './$types'; export const load: PageLoad = async ({ url }) => { + const baseUrl = new URL(url.origin).href || PUBLIC_SITE_URL || 'https://bradleyshellnut.com'; + const currentPageUrl = new URL(url.pathname, url.origin).href; const metaTags: MetaTagsProps = Object.freeze({ title: 'About', description: 'About Bradley Shellnut', openGraph: { title: 'About', description: 'About Bradley Shellnut', - url: new URL(url.pathname, url.origin).href, - } + url: currentPageUrl, + siteName: 'Bradley Shellnut Personal Website', + type: 'website', + locale: 'en_US', + images: [ + { + url: `${baseUrl}b_shell_nut_favicon.gif`, + alt: 'Bradley Shellnut Website Logo', + width: 512, + height: 512 + } + ] + }, + twitter: { + title: 'About', + description: 'About page', + card: 'summary_large_image', + image: `${baseUrl}b_shell_nut_favicon.gif`, + imageAlt: 'Bradley Shellnut Website Logo' + }, + url: currentPageUrl }); return { diff --git a/src/routes/articles/[page]/+page.server.ts b/src/routes/articles/[page]/+page.server.ts index 95a1b8a..1e5277b 100644 --- a/src/routes/articles/[page]/+page.server.ts +++ b/src/routes/articles/[page]/+page.server.ts @@ -1,6 +1,7 @@ import { error } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; import { WALLABAG_MAX_PAGES } from '$env/static/private'; +import { PUBLIC_SITE_URL } from '$env/static/public'; import type { Article } from '$lib/types/article'; export type ArticlePageLoad = { @@ -12,7 +13,7 @@ export type ArticlePageLoad = { cacheControl: string; }; -export const load: PageServerLoad = async ({ fetch, params, setHeaders }) => { +export const load: PageServerLoad = async ({ fetch, params, setHeaders, url }) => { const { page } = params; if (+page > +WALLABAG_MAX_PAGES) { throw error(404, { @@ -32,11 +33,45 @@ export const load: PageServerLoad = async ({ fetch, params, setHeaders }) => { 'cache-control': 'max-age=43200' // 12 hours }); } + + const baseUrl = new URL(url.origin).href || PUBLIC_SITE_URL || 'https://bradleyshellnut.com'; + const currentPageUrl = new URL(url.pathname, url.origin).href; + + const metaTags: MetaTagsProps = Object.freeze({ + title: 'Favorite Articles', + description: 'My favorite articles', + openGraph: { + title: 'Facorite Articles', + description: 'My favorite articles', + url: currentPageUrl, + siteName: 'Bradley Shellnut Personal Website', + type: 'website', + locale: 'en_US', + images: [ + { + url: `${baseUrl}b_shell_nut_favicon.gif`, + alt: 'Bradley Shellnut Website Logo', + width: 512, + height: 512 + } + ] + }, + twitter: { + title: 'Favorite Articles', + description: 'My favorite articles', + card: 'summary_large_image', + image: `${baseUrl}b_shell_nut_favicon.gif`, + imageAlt: 'Bradley Shellnut Website Logo' + }, + url: currentPageUrl + }); + return { articles, currentPage, totalPages, limit, - totalArticles + totalArticles, + metaTagsChild: metaTags }; }; diff --git a/src/routes/portfolio/+page.server.ts b/src/routes/portfolio/+page.server.ts index 82a728f..db27128 100644 --- a/src/routes/portfolio/+page.server.ts +++ b/src/routes/portfolio/+page.server.ts @@ -1,17 +1,40 @@ export const prerender = true; import type { MetaTagsProps } from 'svelte-meta-tags'; +import { PUBLIC_SITE_URL } from '$env/static/public'; import type { PageServerLoad } from './$types'; export const load: PageServerLoad = async ({ url }) => { + const baseUrl = new URL(url.origin).href || PUBLIC_SITE_URL || 'https://bradleyshellnut.com'; + const currentPageUrl = new URL(url.pathname, url.origin).href; + const metaTags: MetaTagsProps = Object.freeze({ title: 'Portfolio', - description: 'Bradley Shellnut\s Portfolio', + description: "Bradley Shellnut's Portfolio", openGraph: { title: 'Portfolio', - description: 'Bradley Shellnut\s Portfolio', - url: new URL(url.pathname, url.origin).href - } + description: "Bradley Shellnut's Portfolio", + url: currentPageUrl, + siteName: 'Bradley Shellnut Personal Website', + type: 'website', + locale: 'en_US', + images: [ + { + url: `${baseUrl}b_shell_nut_favicon.gif`, + alt: 'Bradley Shellnut Website Logo', + width: 512, + height: 512 + } + ] + }, + twitter: { + title: 'Portfolio', + description: "Bradley Shellnut's Portfolio", + card: 'summary_large_image', + image: `${baseUrl}b_shell_nut_favicon.gif`, + imageAlt: 'Bradley Shellnut Website Logo' + }, + url: currentPageUrl }); return { diff --git a/src/routes/privacy/+page.ts b/src/routes/privacy/+page.ts index 1ee6fad..bb01220 100644 --- a/src/routes/privacy/+page.ts +++ b/src/routes/privacy/+page.ts @@ -1,17 +1,40 @@ export const prerender = true; import type { MetaTagsProps } from 'svelte-meta-tags'; +import { PUBLIC_SITE_URL } from '$env/static/public'; import type { PageLoad } from './$types'; export const load: PageLoad = async ({ url }) => { + const baseUrl = new URL(url.origin).href || PUBLIC_SITE_URL || 'https://bradleyshellnut.com'; + const currentPageUrl = new URL(url.pathname, url.origin).href; + const metaTags: MetaTagsProps = Object.freeze({ title: 'Privacy Blog', description: 'My thoughts on personal internet privacy.', openGraph: { title: 'Privacy Blog', description: 'My thoughts on personal internet privacy.', - url: new URL(url.pathname, url.origin).href - } + url: new URL(url.pathname, url.origin).href, + siteName: 'Bradley Shellnut Personal Website', + type: 'website', + locale: 'en_US', + images: [ + { + url: `${baseUrl}b_shell_nut_favicon.gif`, + alt: 'Bradley Shellnut Website Logo', + width: 512, + height: 512 + } + ] + }, + twitter: { + title: 'Privacy Blog', + description: 'My thoughts on personal internet privacy.', + card: 'summary_large_image', + image: `${baseUrl}b_shell_nut_favicon.gif`, + imageAlt: 'Bradley Shellnut Website Logo' + }, + url: currentPageUrl }); return { diff --git a/src/routes/uses/+page.ts b/src/routes/uses/+page.ts index 4be603b..3897a34 100644 --- a/src/routes/uses/+page.ts +++ b/src/routes/uses/+page.ts @@ -1,17 +1,40 @@ export const prerender = true; import type { MetaTagsProps } from 'svelte-meta-tags'; +import { PUBLIC_SITE_URL } from '$env/static/public'; import type { PageLoad } from './$types'; export const load: PageLoad = async ({ url }) => { + const baseUrl = new URL(url.origin).href || PUBLIC_SITE_URL || 'https://bradleyshellnut.com'; + const currentPageUrl = new URL(url.pathname, url.origin).href; + const metaTags: MetaTagsProps = Object.freeze({ - title: 'Portfolio', - description: 'Bradley Shellnuts Portfolio', + title: '/Uses', + description: 'What I use!', openGraph: { - title: 'Portfolio', - description: 'Bradley Shellnuts Portfolio', - url: new URL(url.pathname, url.origin).href - } + title: '/Uses', + description: 'What I use!', + url: new URL(url.pathname, url.origin).href, + siteName: 'Bradley Shellnut Personal Website', + type: 'website', + locale: 'en_US', + images: [ + { + url: `${baseUrl}b_shell_nut_favicon.gif`, + alt: 'Bradley Shellnut Website Logo', + width: 512, + height: 512 + } + ] + }, + twitter: { + title: '/Uses', + description: "What I use!", + card: 'summary_large_image', + image: `${baseUrl}b_shell_nut_favicon.gif`, + imageAlt: 'Bradley Shellnut Website Logo' + }, + url: currentPageUrl }); return {