-
-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(website): Move blog to CC and fix RSS (#937)
Co-authored-by: Emanuele Stoppa <[email protected]>
- Loading branch information
1 parent
d7a5d8c
commit c449679
Showing
15 changed files
with
467 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,63 @@ | ||
--- | ||
import "@src/styles/blog/index.scss"; | ||
import { getEntry, type CollectionEntry } from "astro:content"; | ||
export interface Props { | ||
frontmatter: { | ||
coauthorName?: string; | ||
coauthorAvatar?: string; | ||
authorName: string; | ||
authorUrl?: string; | ||
authorAvatar?: string; | ||
pubDate: string; | ||
}; | ||
post: CollectionEntry<"blog">["data"]; | ||
} | ||
async function getAuthorsData( | ||
authors: CollectionEntry<"authors">["id"][] | ||
): Promise<CollectionEntry<"authors">[]> { | ||
const authorsData = await Promise.all( | ||
authors.map((author) => getEntry("authors", author)) | ||
); | ||
return authorsData; | ||
} | ||
const {coauthorName, coauthorAvatar, authorName, authorUrl, authorAvatar, pubDate} = Astro.props.frontmatter; | ||
const { post } = Astro.props; | ||
const authors = await getAuthorsData( | ||
post.authors as CollectionEntry<"authors">["id"][] | ||
); | ||
--- | ||
|
||
<div class="blog-info"> | ||
<div> | ||
|
||
<span class="avatar-stack"> | ||
<span class="avatar"><img src={authorAvatar}></span> | ||
{coauthorAvatar && <span class="avatar"><img src={coauthorAvatar}></span>} | ||
</span> | ||
|
||
{authorUrl ? <a href={authorUrl}><span>{authorName}</span></a> : <span>{authorName}</span>} | ||
<span class="avatar-stack"> | ||
{ | ||
authors.map(({ data: author }) => ( | ||
<span class="avatar"> | ||
<img src={author.avatar} /> | ||
</span> | ||
)) | ||
} | ||
</span> | ||
|
||
{coauthorName && <span> & {coauthorName}</span>} | ||
</div> | ||
<div class="author-list"> | ||
{ | ||
authors.map((author, index) => ( | ||
<> | ||
{author.data.url ? ( | ||
<a href={author.data.url}> | ||
<span>{author.data.name}</span> | ||
</a> | ||
) : ( | ||
<span>{author.data.name}</span> | ||
)} | ||
{authors.length > 1 && index + 1 == authors.length - 1 ? " & " : ""} | ||
{authors.length > 1 && index + 1 < authors.length - 1 ? ", " : ""} | ||
</> | ||
)) | ||
} | ||
</div> | ||
|
||
<time datetime={pubDate}>{new Date(pubDate).toLocaleDateString(undefined, { | ||
year: "numeric", | ||
month: "long", | ||
day: "numeric", | ||
timeZone: "UTC", | ||
})}</time> | ||
<time datetime={post.pubDate.toString()} | ||
>{ | ||
post.pubDate.toLocaleDateString(undefined, { | ||
year: "numeric", | ||
month: "long", | ||
day: "numeric", | ||
timeZone: "UTC", | ||
}) | ||
}</time | ||
> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
--- | ||
import InlineSVG from "@src/components/InlineSVG.astro"; | ||
import BlogPostInfo from "@src/components/BlogPostInfo.astro"; | ||
import "@src/styles/blog/index.scss"; | ||
import { getCollection } from "astro:content"; | ||
let posts = await Astro.glob("../content/docs/blog/**/*.(mdx|md)"); | ||
posts = posts.sort((a, b) => { | ||
return new Date(b.frontmatter.pubDate).valueOf() - new Date(a.frontmatter.pubDate).valueOf(); | ||
}); | ||
const posts = (await getCollection("blog")).sort( | ||
(a, b) => | ||
new Date(b.data.pubDate).valueOf() - new Date(a.data.pubDate).valueOf() | ||
); | ||
--- | ||
|
||
<div class="blog"> | ||
<a href="/feed.xml" class="rss-icon"><InlineSVG src="rss" /><span class="sr-only">RSS</span></a> | ||
<a href="/feed.xml" class="rss-icon" | ||
><InlineSVG src="rss" /><span class="sr-only">RSS</span></a | ||
> | ||
|
||
<section class="blog"></section> | ||
{posts.filter(post => post.frontmatter.url).map((post) => <article> | ||
<h2><a href={post.frontmatter.url}>{post.frontmatter.title}</a></h2> | ||
<BlogPostInfo frontmatter={post.frontmatter} /> | ||
<Fragment set:html={post.frontmatter.summary} /> | ||
<p><a href={post.frontmatter.url}>Read more</a></p> | ||
</article>)} | ||
<section class="blog"></section> | ||
{ | ||
posts.map(async (post) => ( | ||
<article> | ||
<h2> | ||
<a href={`blog/${post.slug}`}>{post.data.title}</a> | ||
</h2> | ||
<BlogPostInfo post={post.data} /> | ||
<Fragment set:html={post.data.summary} /> | ||
<p> | ||
<a href={`blog/${post.slug}`}>Read more</a> | ||
</p> | ||
</article> | ||
)) | ||
} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "Biome Core Team", | ||
"avatar": "/img/circle-indent-logo.svg" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Emanuele Stoppa", | ||
"avatar": "https://avatars.githubusercontent.com/u/602478?v=4", | ||
"url": "https://twitter.com/ematipico" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "Biome Core Team, Biome Maintainers", | ||
"avatar": "/img/circle-indent-logo.svg" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.