Skip to content

site: allow multiple blog authors #9390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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. Let’s 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).
Expand Down
10 changes: 6 additions & 4 deletions sites/svelte.dev/src/lib/server/blog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
});
}
Expand Down
4 changes: 2 additions & 2 deletions sites/svelte.dev/src/lib/server/blog/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
9 changes: 8 additions & 1 deletion sites/svelte.dev/src/routes/blog/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down