Add support for dynamic authors on blog posts
This commit is contained in:
parent
e0de86bb5a
commit
7cad2d9c13
@ -3,7 +3,7 @@ import Image from 'next/image'
|
||||
import designSystem from './planetaria-design-system.png'
|
||||
|
||||
export const article = {
|
||||
author: 'Adam Wathan',
|
||||
author: 'Tony Grosinger',
|
||||
date: '2022-09-05',
|
||||
title: 'Crafting a design system for a multiplanetary future',
|
||||
description:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ArticleLayout } from '@/components/ArticleLayout'
|
||||
|
||||
export const article = {
|
||||
author: 'Adam Wathan',
|
||||
author: 'Tony Grosinger',
|
||||
date: '2022-09-02',
|
||||
title: 'Introducing Animaginary: High performance web animations',
|
||||
description:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ArticleLayout } from '@/components/ArticleLayout'
|
||||
|
||||
export const article = {
|
||||
author: 'Adam Wathan',
|
||||
author: 'Tony Grosinger',
|
||||
date: '2022-07-14',
|
||||
title: 'Rewriting the cosmOS kernel in Rust',
|
||||
description:
|
||||
|
@ -2,6 +2,18 @@ import assert from 'assert';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { Feed } from 'feed';
|
||||
|
||||
interface Author {
|
||||
name: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
const authors: Record<string, Author> = {
|
||||
'Tony Grosinger': {
|
||||
name: 'Tony Grosinger',
|
||||
email: 'tony@grosinger.net',
|
||||
},
|
||||
};
|
||||
|
||||
export async function GET(req: Request) {
|
||||
let siteUrl = process.env.NEXT_PUBLIC_SITE_URL;
|
||||
|
||||
@ -9,15 +21,10 @@ export async function GET(req: Request) {
|
||||
throw Error('Missing NEXT_PUBLIC_SITE_URL environment variable');
|
||||
}
|
||||
|
||||
let author = {
|
||||
name: 'Spencer Sharp',
|
||||
email: 'spencer@planetaria.tech',
|
||||
};
|
||||
|
||||
let feed = new Feed({
|
||||
title: author.name,
|
||||
description: 'Your blog description',
|
||||
author,
|
||||
title: 'West Sound Community Hall',
|
||||
description:
|
||||
'History, Announcements, and more from the West Sound Hall and Community Club.',
|
||||
id: siteUrl,
|
||||
link: siteUrl,
|
||||
image: `${siteUrl}/favicon.ico`,
|
||||
@ -43,6 +50,7 @@ export async function GET(req: Request) {
|
||||
let article = $('article').first();
|
||||
let title = article.find('h1').first().text();
|
||||
let date = article.find('time').first().attr('datetime');
|
||||
let author = article.find('#byline').first().text().slice(3); // Remove "by " from beginning
|
||||
let content = article.find('[data-mdx-content]').first().html();
|
||||
|
||||
assert(typeof title === 'string');
|
||||
@ -54,8 +62,8 @@ export async function GET(req: Request) {
|
||||
id: publicUrl,
|
||||
link: publicUrl,
|
||||
content,
|
||||
author: [author],
|
||||
contributor: [author],
|
||||
author: [authors[author]],
|
||||
contributor: [authors[author]],
|
||||
date: new Date(date),
|
||||
});
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ import '@/styles/tailwind.css'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: {
|
||||
template: '%s - Spencer Sharp',
|
||||
template: '%s - West Sound Hall',
|
||||
default:
|
||||
'Spencer Sharp - Software designer, founder, and amateur astronaut',
|
||||
'West Sound Hall - A community space on Orcas Island',
|
||||
},
|
||||
description:
|
||||
'I’m Spencer, a software designer and entrepreneur based in New York City. I’m the founder and CEO of Planetaria, where we develop technologies that empower regular people to explore space on their own terms.',
|
||||
'WestSound Community Hall, located at 884 Deer Harbor Road in the hamlet of West Sound, has served as a public assembly hall since it was built by volunteers in 1902.',
|
||||
alternates: {
|
||||
types: {
|
||||
'application/rss+xml': `${process.env.NEXT_PUBLIC_SITE_URL}/feed.xml`,
|
||||
|
@ -58,6 +58,7 @@ export function ArticleLayout({
|
||||
<span className="h-4 w-0.5 rounded-full bg-zinc-200 dark:bg-zinc-500" />
|
||||
<span className="ml-3">{formatDate(article.date)}</span>
|
||||
</time>
|
||||
<span id="byline" className='mt-4 text-base text-zinc-400 dark:text-zinc-500'>by {article.author}</span>
|
||||
</header>
|
||||
<Prose className="mt-8" data-mdx-content>
|
||||
{children}
|
||||
|
@ -32,8 +32,7 @@ export function Footer() {
|
||||
<NavLink href="/club">Club</NavLink>
|
||||
</div>
|
||||
<p className="text-sm text-zinc-400 dark:text-zinc-500">
|
||||
© {new Date().getFullYear()} Spencer Sharp. All rights
|
||||
reserved.
|
||||
© {new Date().getFullYear()} West Sound Community Club. All rights reserved.
|
||||
</p>
|
||||
</div>
|
||||
</ContainerInner>
|
||||
|
Loading…
Reference in New Issue
Block a user