site: allow multiple blog authors (#9390)

pull/9399/merge
Geoff Rich 8 months ago committed by GitHub
parent 1369aa5cec
commit 022c47edfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,8 @@
---
title: Streaming, snapshots, and other new features since SvelteKit 1.0
description: Exciting improvements in the latest version of SvelteKit
author: Geoff Rich
authorURL: https://geoffrich.net
author: Geoff Rich, Rich Harris
authorURL: https://geoffrich.net, https://twitter.com/Rich_Harris
---
The Svelte team has been hard at work since the release of SvelteKit 1.0. Lets talk about some of the major new features that have shipped since launch: [streaming non-essential data](https://kit.svelte.dev/docs/load#streaming-with-promises), [snapshots](https://kit.svelte.dev/docs/snapshots), and [route-level config](https://kit.svelte.dev/docs/page-options#config).

@ -35,6 +35,8 @@ export async function get_blog_data(base = CONTENT_BASE_PATHS.BLOG) {
const { date, date_formatted, slug } = get_date_and_slug(file);
const { metadata, body } = extractFrontmatter(await readFile(`${base}/${file}`, 'utf-8'));
const authors = metadata.author.split(',').map((author) => author.trim());
const authorUrls = metadata.authorURL.split(',').map((author) => author.trim());
blog_posts.push({
date,
@ -45,10 +47,10 @@ export async function get_blog_data(base = CONTENT_BASE_PATHS.BLOG) {
slug,
title: metadata.title,
file,
author: {
name: metadata.author,
url: metadata.authorURL
},
authors: authors.map((author, i) => ({
name: author,
url: authorUrls[i]
})),
sections: await get_sections(body)
});
}

@ -7,10 +7,10 @@ export interface BlogPost {
date_formatted: string;
slug: string;
file: string;
author: {
authors: {
name: string;
url?: string;
};
}[];
draft: boolean;
content: string;
sections: Section[];

@ -26,7 +26,14 @@
<p class="standfirst">{data.post.description}</p>
<p class="byline">
<a href={data.post.author.url}>{data.post.author.name}</a>
{#each data.post.authors as author, i}
{@const show_comma = data.post.authors.length > 2 && i < data.post.authors.length - 1}
{@const show_and = i === data.post.authors.length - 2}
<svelte:element this={author.url ? 'a' : 'span'} href={author.url}
>{author.name}</svelte:element
>{#if show_comma},&nbsp;{/if}
{#if show_and}and&nbsp;{/if}
{/each}
<time datetime={data.post.date}>{data.post.date_formatted}</time>
</p>

Loading…
Cancel
Save