diff --git a/website/astro.config.ts b/website/astro.config.ts index 0a47322e4b01..7bcdfdeb1b42 100644 --- a/website/astro.config.ts +++ b/website/astro.config.ts @@ -108,6 +108,10 @@ export default defineConfig({ compressHTML: true, + image: { + domains: ["avatars.githubusercontent.com"], + }, + integrations: [ react(), starlight({ diff --git a/website/public/img/blog/announcing-biome/biome-logo-slogan.png b/website/public/img/blog/announcing-biome/biome-logo-slogan.png deleted file mode 100644 index 7be42507dbe4..000000000000 Binary files a/website/public/img/blog/announcing-biome/biome-logo-slogan.png and /dev/null differ diff --git a/website/public/img/blog/announcing-biome/JsNation_2023.jpg b/website/src/assets/blog/announcing-biome/JsNation_2023.jpg similarity index 100% rename from website/public/img/blog/announcing-biome/JsNation_2023.jpg rename to website/src/assets/blog/announcing-biome/JsNation_2023.jpg diff --git a/website/public/img/blog/prettier-challenge.png b/website/src/assets/blog/prettier-challenge.png similarity index 100% rename from website/public/img/blog/prettier-challenge.png rename to website/src/assets/blog/prettier-challenge.png diff --git a/website/src/components/BlogPostInfo.astro b/website/src/components/BlogPostInfo.astro index ecc79e63344c..efc812737967 100755 --- a/website/src/components/BlogPostInfo.astro +++ b/website/src/components/BlogPostInfo.astro @@ -1,6 +1,7 @@ --- import "@src/styles/blog/index.scss"; import { getEntry, type CollectionEntry } from "astro:content"; +import { Image } from "astro:assets"; export interface Props { post: CollectionEntry<"blog">["data"]; @@ -26,7 +27,7 @@ const authors = await getAuthorsData( { authors.map(({ data: author }) => ( - + )) } diff --git a/website/src/content/blog/annoucing-biome.mdx b/website/src/content/blog/annoucing-biome.mdx index beee35ed75c2..34fe27582f7e 100644 --- a/website/src/content/blog/annoucing-biome.mdx +++ b/website/src/content/blog/annoucing-biome.mdx @@ -7,9 +7,9 @@ authors: - core pubDate: 2023-08-29 coverImage: - src: blog/announcing-biome/biome-logo-slogan.png + src: ../../assets/social-logo.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 +socialImage: ../../assets/social-logo.png --- We are happy to announce Biome, _toolchain of the web_. @@ -60,11 +60,7 @@ A few new [OSS contributors](#the-core-team) joined the cause and helped in cont In June, I [gave a talk](https://portal.gitnation.org/contents/rome-a-modern-toolchain) about Rome at JsNation 2023. -Emanuele Stoppa on the stage of JsNation +![Emanuele Stoppa on the stage of JsNation](../../assets/blog/announcing-biome/JsNation_2023.jpg) So, the project is still alive, but maintaining it has become challenging: diff --git a/website/src/content/blog/biome-v1.mdx b/website/src/content/blog/biome-v1.mdx index 42a09bbc5e0d..edd0ac598b53 100644 --- a/website/src/content/blog/biome-v1.mdx +++ b/website/src/content/blog/biome-v1.mdx @@ -6,7 +6,7 @@ authors: - ema - core pubDate: 2023-08-29 -socialImage: social-logo.png +socialImage: ../../assets/social-logo.png --- In Biome v1, the formatter has options for JSX quotes and parentheses in the arrow functions; the CLI adds a new command `biome lint`, `.jsonc` files are supported, and it's possible to extend the configuration file. diff --git a/website/src/content/blog/biome-wins-prettier-challenge.md b/website/src/content/blog/biome-wins-prettier-challenge.md index cc753dc62179..f9412e8c9c53 100644 --- a/website/src/content/blog/biome-wins-prettier-challenge.md +++ b/website/src/content/blog/biome-wins-prettier-challenge.md @@ -7,9 +7,9 @@ authors: - team pubDate: 2023-11-27 coverImage: - src: blog/prettier-challenge.png + src: ../../assets/blog/prettier-challenge.png alt: The Prettier challenge banner, with the Biome logo over it -socialImage: blog/prettier-challenge.png +socialImage: ../../assets/blog/prettier-challenge.png --- With the release of Biome **`v1.4.0`**, we claim the bounty of the [Prettier challenge](https://console.algora.io/challenges/prettier)! diff --git a/website/src/content/config.ts b/website/src/content/config.ts index 90e2a7cb1381..e273f1bc0448 100644 --- a/website/src/content/config.ts +++ b/website/src/content/config.ts @@ -1,38 +1,39 @@ import { docsSchema } from "@astrojs/starlight/schema"; // src/content/config.ts -import { defineCollection, z } from "astro:content"; +import { type ImageFunction, defineCollection, z } from "astro:content"; -const blogSchema = z.object({ - title: z.string(), - subtitle: z.string().optional(), - pubDate: z - .string() - .or(z.date()) - .transform((val) => new Date(val)), - summary: z.string(), - description: z.string(), - authors: z.array(z.string()), - coverImage: z - .object({ - src: z.string(), - caption: z.string().optional(), - alt: z.string(), - }) - .optional(), - socialImage: z.string(), -}); +const blogSchema = (image: ImageFunction) => + z.object({ + title: z.string(), + subtitle: z.string().optional(), + pubDate: z + .string() + .or(z.date()) + .transform((val) => new Date(val)), + summary: z.string(), + description: z.string(), + authors: z.array(z.string()), + coverImage: z + .object({ + src: image(), + caption: z.string().optional(), + alt: z.string(), + }) + .optional(), + socialImage: image(), + }); const authorsSchema = z.object({ name: z.string(), avatar: z.string(), - url: z.string().optional(), + url: z.string().url().optional(), }); export const collections = { docs: defineCollection({ schema: docsSchema() }), blog: defineCollection({ type: "content", - schema: blogSchema, + schema: ({ image }) => blogSchema(image), }), authors: defineCollection({ type: "data", diff --git a/website/src/layouts/Blog.astro b/website/src/layouts/Blog.astro index fb6c5ab8f447..9a13565e606c 100644 --- a/website/src/layouts/Blog.astro +++ b/website/src/layouts/Blog.astro @@ -1,6 +1,7 @@ --- import type { CollectionEntry } from "astro:content"; import BlogPostInfo from "@src/components/BlogPostInfo.astro"; +import { Image } from "astro:assets"; export interface Props { post: CollectionEntry<"blog">["data"]; @@ -13,7 +14,7 @@ const { post } = Astro.props; { post.coverImage && (
- {post.coverImage.alt} + {post.coverImage.alt} {post.coverImage.caption && (
{post.coverImage.caption} diff --git a/website/src/layouts/StarlightSplashLayout.astro b/website/src/layouts/StarlightSplashLayout.astro index 661f92859539..e196dc8c1c7c 100644 --- a/website/src/layouts/StarlightSplashLayout.astro +++ b/website/src/layouts/StarlightSplashLayout.astro @@ -5,11 +5,17 @@ import Page from "@astrojs/starlight/components/Page.astro"; export interface Props { title: string; + description: string; slug: string; + head?: Array<{ + tag: string; + attrs?: Record; + content?: string; + }>; editUrl?: string; } -function getPageProps(title: string, slug: string, editUrl?: string) { +function getPageProps({ title, description, slug, head = [], editUrl }: Props) { const entryMeta = { dir: "ltr", lang: "en", locale: undefined } as LocaleData; return { @@ -22,9 +28,11 @@ function getPageProps(title: string, slug: string, editUrl?: string) { tag: "title", content: `${title} | Biome`, }, + ...head, ], pagefind: false, title, + description, template: "splash", }, slug, @@ -48,9 +56,7 @@ function getPageProps(title: string, slug: string, editUrl?: string) { }; } -const { title, slug, editUrl } = Astro.props; - -const pageProps = getPageProps(title, slug, editUrl); +const pageProps = getPageProps(Astro.props); --- diff --git a/website/src/pages/blog/[...slug].astro b/website/src/pages/blog/[...slug].astro index 13e703b40435..3568c8dbe946 100644 --- a/website/src/pages/blog/[...slug].astro +++ b/website/src/pages/blog/[...slug].astro @@ -2,6 +2,7 @@ import { getCollection, type CollectionEntry } from "astro:content"; import BlogLayout from "@src/layouts/Blog.astro"; import StarlightSplashLayout from "@src/layouts/StarlightSplashLayout.astro"; +import { getImage } from "astro:assets"; export async function getStaticPaths() { const blogEntries = await getCollection("blog"); @@ -19,11 +20,36 @@ const { entry } = Astro.props; const { Content } = await entry.render(); const post = entry.data; + +const processedImage = await getImage({ src: post.socialImage }); +const socialImageUrl = new URL( + processedImage.src, + `${Astro.url.origin}/` +).toString(); + +const head = [ + { + tag: "meta", + attrs: { + property: "og:image", + content: socialImageUrl, + }, + }, + { + tag: "meta", + attrs: { + property: "twitter:image", + content: socialImageUrl, + }, + }, +]; --- diff --git a/website/src/pages/blog/index.astro b/website/src/pages/blog/index.astro index e39366462c94..2c944bca70ad 100644 --- a/website/src/pages/blog/index.astro +++ b/website/src/pages/blog/index.astro @@ -3,6 +3,10 @@ import PostsList from "@src/components/PostsList.astro"; import StarlightSplashLayout from "@src/layouts/StarlightSplashLayout.astro"; --- - +