Skip to content

Commit

Permalink
fixup! fixup! Switch from Gatsby to Astro
Browse files Browse the repository at this point in the history
  • Loading branch information
john-kurkowski committed May 2, 2024
1 parent 0ad25b6 commit 246197c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/components/layouts/Seo.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
const { page, siteMetadata } = Astro.props
const { frontmatter, siteMetadata } = Astro.props
let title: string
if (page.title && page.title.includes(siteMetadata.title)) {
title = page.title
} else if (page.title) {
title = `${page.title} - ${siteMetadata.title}`
if (frontmatter.title?.includes(siteMetadata.title)) {
title = frontmatter.title
} else if (frontmatter.title) {
title = `${frontmatter.title} - ${siteMetadata.title}`
} else {
title = siteMetadata.title
}
const description = page.description || siteMetadata.description
const date = frontmatter.date ? new Date(frontmatter.date) : null
const description = frontmatter.description || siteMetadata.description
---

<title>{title}</title>
Expand All @@ -22,7 +24,7 @@ const description = page.description || siteMetadata.description
<meta name='description' content={description} />
<meta name='twitter:description' content={description} />

{page.dateForMeta && <meta httpEquiv='date' content={page.dateForMeta} />}
{date && <meta httpEquiv='date' content={date} />}

<meta charset='utf-8' />
<meta content='John' key='profile:first_name' property='profile:first_name' />
Expand Down
4 changes: 2 additions & 2 deletions src/components/layouts/base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Footer from './Footer.astro'
import Nav from './Nav.astro'
import Seo from './Seo.astro'
const page = Astro.props
const frontmatter = Astro.props.frontmatter || {}
const siteMetadata = {
description:
Expand All @@ -16,7 +16,7 @@ const siteMetadata = {
---

<html class='bg-secondary' lang='en-US'>
<Seo page={page} siteMetadata={siteMetadata} />
<Seo frontmatter={frontmatter} siteMetadata={siteMetadata} />
<body>
<div class='flex min-h-full flex-col content-between font-serif'>
<div class='flex-grow bg-background'>
Expand Down
2 changes: 1 addition & 1 deletion src/components/layouts/page.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Layout from './base.astro'
const { frontmatter } = Astro.props
---

<Layout>
<Layout frontmatter={frontmatter}>
<article>
<header class='post'>
<h2>{frontmatter.title}</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/components/layouts/post.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const DATE_DISPLAY_FORMAT = new Intl.DateTimeFormat('en-GB', {
})
---

<Layout>
<Layout frontmatter={frontmatter}>
<div class='text-sm'>
<a class='link' href='/posts'> ↩ to Articles </a>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/posts/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ export function slugify(entry: CollectionEntry) {
return filenameNoDateNoExt
}
const frontmatter = {
title: 'Articles',
}
const posts = await getCollection('posts')
posts.reverse()
---

<Layout>
<Layout frontmatter={frontmatter}>
<section class=''>
<h2 class='heading text-3xl'>Articles</h2>

Expand Down

0 comments on commit 246197c

Please sign in to comment.