Skip to content

Commit

Permalink
Merge pull request #85 from tjheffner/add-gallery
Browse files Browse the repository at this point in the history
minor updates
  • Loading branch information
tjheffner authored Jan 20, 2024
2 parents a0b922c + 5c55fc2 commit 371f8b9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/routes/(main)/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
<section class="mx-auto px-4 sm:p-0 flex w-full flex-col items-start">
<Slice>
<h1 class="text-3xl lg:text-5xl font-bold text-shadow">
welcome to my page 🌊
🌊 welcome to my page 🌊
</h1>
</Slice>

<Slice title="Hello World!">
<p>This site is perpetually under construction but coming along :)</p>
<p>This site is perpetually under construction but coming along. 😎</p>

<p>It's mostly a place for me to post <a href="/blog?show=Recipes">recipes I like</a> and <a href="/gallery">travel photos</a>, with the occasional technical post or personal blog mixed in. Some <a href="/work">work-related</a> <a href="/resume">stuff</a> can be found here too, but that's not what I want to talk <a href="/about">about</a>.<p>

Expand Down
7 changes: 6 additions & 1 deletion src/routes/(main)/[slug]/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ export const csr = true; // https://github.com/sveltejs/kit/pull/6446
export async function load({ params, fetch, setHeaders }) {
const slug = params.slug;

// redirect these slugs to appropriate routes
if (slug === 'feed' || slug === 'rss' || slug === 'rss.xml') {
throw redirect(308, '/rss.xml')
}
if (slug === 'sitemap' || slug === 'sitemap.xml') {
throw redirect(308, '/sitemap.xml')
}

let res = null;
res = await fetch(`/api/getContent/${slug}.json`);
Expand All @@ -16,7 +20,8 @@ export async function load({ params, fetch, setHeaders }) {
}
const json = await res.json()

// because [slug] is a catchall, it gets the gallery pages too. redirect them.
// because [slug] is a catchall, it gets gallery slugs too. redirect them.
// e.g. /japan -> /gallery/japan
if (json.type === 'gallery') {
throw redirect(308, `/gallery/${json.slug}`)
}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(main)/gallery/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</script>

<svelte:head>
<title>heffner.dev | adventures</title>
<meta name="description" content="part photo gallery, part trip report" />
<title>heffner.dev | gallery</title>
<meta name="description" content="part photo gallery, part adventure log" />
<meta property="og:image" content={`https://heffner.dev/og?message=adventure%20log`}>
<meta name="twitter:card" content={`https://heffner.dev/og?message=adventure%20log` ? 'summary_large_image' : 'summary'} />
<meta name="twitter:image" content={`https://heffner.dev/og?message=adventure%20log`} />
Expand Down
27 changes: 0 additions & 27 deletions src/routes/api/listGallery.json/+server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,6 @@ import { listContentFromIssues } from '$lib/content';
export async function GET({ setHeaders }) {
const list = await listContentFromIssues('Gallery');

// const list = [
// {
// name: 'Japan',
// date: 'April 2023',
// description: 'traveled all over the country for a month with randi',
// slug: '/gallery/japan',
// image: 'http://placekitten.com/400/400',
// alt: 'japan alt'
// },
// {
// name: 'Morocco',
// date: 'September 2018',
// description: 'visited my sister during her peace corps mission',
// slug: '/gallery/morocco',
// image: 'http://placekitten.com/400/400',
// alt: 'morocco alt'
// },
// {
// name: 'Costa Rica',
// date: 'December 2017',
// description: 'two weeks of desayuno tipica with the boys',
// slug: '/gallery/costa-rica',
// image: 'http://placekitten.com/400/400',
// alt: 'cr alt'
// },
// ];

setHeaders({
'Cache-Control': `max-age=0, s-maxage=${60}` // 1 minute.. for now
});
Expand Down
6 changes: 3 additions & 3 deletions src/routes/sitemap.xml/+server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function GET({ fetch }) {
const galleries = await listContentFromIssues('Gallery');
const projects = await fetchMarkdownPosts()
const pages = ['about', 'resume', 'blogroll', 'christmas', 'blog', 'work'];
const body = sitemap(posts, projects, pages);
const body = sitemap(posts, projects, pages, galleries);

return new Response(body, {
headers: {
Expand All @@ -18,7 +18,7 @@ export async function GET({ fetch }) {
});
}

const sitemap = (posts, projects, pages) => `<?xml version="1.0" encoding="UTF-8" ?>
const sitemap = (posts, projects, pages, galleries) => `<?xml version="1.0" encoding="UTF-8" ?>
<urlset
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9"
Expand Down Expand Up @@ -50,7 +50,7 @@ const sitemap = (posts, projects, pages) => `<?xml version="1.0" encoding="UTF-8
).join('')}
${galleries
.map((gallery) =>
post.isPrivate
gallery.isPrivate
? null
: `
<url>
Expand Down

0 comments on commit 371f8b9

Please sign in to comment.