Skip to content
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

feat(website): Move blog to CC and fix RSS #937

Merged
merged 4 commits into from
Nov 29, 2023
Merged

feat(website): Move blog to CC and fix RSS #937

merged 4 commits into from
Nov 29, 2023

Conversation

yanthomasdev
Copy link
Contributor

Summary

The current blog was using the old recommended method for querying content (Astro.glob()) which had several disadvantages in comparison to the current approach, named Content Collections.

This PR moves the entire blog set up to the recommended approach, refactors the internal blog components used, and as a bonus, fixes the generated RSS which was empty before.

There are some considerable changes for the team to be aware of:

  1. Content should now be written in src/content/blog instead of src/content/docs/blog.

  2. All blog posts now have a different set of frontmatter properties. I went for a very similar structure, but a few properties weren't necessary anymore or could be improved, for example:

    Before:

    ---
    title: Announcing Biome
    template: splash
    url: /blog/annoucing-biome
    description: Biome continues Rome's legacy; in this blog post, we explain why the fork, with some context and history.
    summary: Biome continues Rome's legacy; in this blog post, we explain why the fork, with some context and history.
    authorName: Emanuele Stoppa
    authorAvatar: https://avatars.githubusercontent.com/u/602478?v=4
    authorUrl: https://twitter.com/ematipico
    coauthorName: Biome Core Team
    coauthorAvatar: /img/circle-indent-logo.svg
    pubDate: 2023-08-29
    layout: ../../../layouts/Blog.astro
    coverImage: blog/announcing-biome/biome-logo-slogan.png
    coverImageAltText: The name of the project - "Biome", with the slogan underneath that says "Toolchain of the web"
    socialImage: blog/announcing-biome/biome-logo-slogan.png
    ---

    After:

    ---
    title: Announcing Biome
    description: Biome continues Rome's legacy; in this blog post, we explain why the fork, with some context and history.
    summary: Biome continues Rome's legacy; in this blog post, we explain why the fork, with some context and history.
    authors:
      - ema
      - core
    pubDate: 2023-08-29
    coverImage:
      src: blog/announcing-biome/biome-logo-slogan.png
      alt: The name of the project - "Biome", with the slogan underneath that says "Toolchain of the web"
    socialImage: blog/announcing-biome/biome-logo-slogan.png
    ---
  3. Authors are now .json files inside src/content/authors.

    To create a new author, create a new (author).json file following the format:

    {
    	"name": "Emanuelle Stoppa",
    	"avatar": "https://avatars.githubusercontent.com/u/602478?v=4",
    	"url": "https://twitter.com/ematipico" // This is optional!
    }

    And to reference it inside a blog post (the author reference id will be its file name without the extension):

    ---
    authors:
      - ema
    ---

    Note that authors are shown in a blog post in the order specified in the frontmatter, meaning you can decide who's the main author according to the blog post.

Test Plan

By visually inspecting the deploy preview you can see how all blog posts are as expected.

For the RSS fix, this is the snippet of current RSS feed and the one built by this PR:

Before:

<rss version="2.0">
	<channel>
		<title>Biome Blog</title>
		<description/>
		<link>https://biomejs.dev/</link>
		<language>en-us</language>
	</channel>
</rss>

After:

<rss version="2.0">
	<channel>
		<title>Biome Blog</title>
		<description>Biome's toolchain official blog</description>
		<link>https://biomejs.dev/</link>
		<language>en-us</language>
		<item>
			<title>Biome formatter wins the Prettier challenge</title>
			<link>https://biomejs.dev/blog/biome-wins-prettier-challenge/</link>
			<guid isPermaLink="true">https://biomejs.dev/blog/biome-wins-prettier-challenge/</guid>
			<description>Biome formatter now 95% compatible with Prettier</description>
			<pubDate>Mon, 27 Nov 2023 00:00:00 GMT</pubDate>
		</item>
		<item>
			<title>Announcing Biome</title>
			<link>https://biomejs.dev/blog/annoucing-biome/</link>
			<guid isPermaLink="true">https://biomejs.dev/blog/annoucing-biome/</guid>
			<description>Biome continues Rome's legacy; in this blog post, we explain why the fork, with some context and history.</description>
			<pubDate>Tue, 29 Aug 2023 00:00:00 GMT</pubDate>
		</item>
		<item>
			<title>Biome v1</title>
			<link>https://biomejs.dev/blog/biome-v1/</link>
			<guid isPermaLink="true">https://biomejs.dev/blog/biome-v1/</guid>
			<description>New formatter options, CLI improvements, JSONC support and more.</description>
			<pubDate>Tue, 29 Aug 2023 00:00:00 GMT</pubDate>
		</item>
	</channel>
</rss>

@github-actions github-actions bot added the A-Website Area: website label Nov 28, 2023
import type { LocaleData } from "@astrojs/starlight/utils/slugs";
import Page from "@astrojs/starlight/components/Page.astro";

export interface Props {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yan-Thomas I think we could use this layout for Playground page too
Maybe we just need to hide the page title, do you think it's possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I thought when I saw the website rework issue, should be straightforward in theory.

I'd say to keep this layout like so and then tackle a refactor in the Playground PR so we abstract it properly, as there might be a few edge cases to consider and as I also am not familiarized with the current Playground implementation.

@victor-teles
Copy link
Contributor

@Yan-Thomas Let's change the base branch to website-v2

@yanthomasdev yanthomasdev changed the base branch from main to website-v2 November 29, 2023 11:21
@yanthomasdev yanthomasdev changed the base branch from website-v2 to main November 29, 2023 11:22
@yanthomasdev
Copy link
Contributor Author

Let's change the base branch to website-v2

Any particular reason @victor-teles? I thought this branch was for the rebranding, and considering this PR mostly fixes/improves what we already had I think we can merge it into main and update branch on website-v2, so people there can also use the new layout. I won't argue against it though, it's your call!

@ematipico
Copy link
Member

Yeah there's no need. We can merge this PR in main :)

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work @Yan-Thomas, thank you! ❤️

website/src/content/authors/ema.json Outdated Show resolved Hide resolved
import { defineCollection } from "astro:content";
import { defineCollection, z } from "astro:content";

const blogSchema = z.object({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love content collections!

@ematipico ematipico merged commit c449679 into biomejs:main Nov 29, 2023
4 checks passed
yossydev pushed a commit to yossydev/biome that referenced this pull request Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Website Area: website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants