HiDeoo / starlight-blog

Starlight plugin to add a blog to your documentation
https://starlight-blog-docs.vercel.app
MIT License
106 stars 10 forks source link

Support for social images #53

Closed ematipico closed 1 week ago

ematipico commented 1 week ago

Is your feature request related to a problem?

It would be nice to allow to add social images and an hero images. I say plural because I would expect to handle/provide images for dark and light themes.

Describe the solution you'd like

Optional fields in the frontmatter should be enough

Describe alternatives you've considered

No response

Additional Context

I wanted to move the Biome blog to this integration, but we would lost the social images

ematipico commented 1 week ago

Use case: https://biomejs.dev/blog/biome-v1-7/

A hero image like here, with the possibility to add social images

HiDeoo commented 1 week ago

Thanks for the feature request :raised_hands:

Cover/hero images will be supported in the next version of the plugin. Either a single image or different images to use in dark and light mode could be configured in the frontmatter of a blog post.

Note that this will require a small change to the Starlight’s content collections configuration in the src/content/config.ts file:

 import { defineCollection } from 'astro:content';
 import { docsSchema } from '@astrojs/starlight/schema';
 import { blogSchema } from 'starlight-blog/schema'

export const collections = {
- docs: defineCollection({ schema: docsSchema({ extend: blogSchema() }) }),
+ docs: defineCollection({ schema: docsSchema({ extend: (context) => blogSchema(context) }) }),
}

This change will be included in the release notes.

Regarding social images, I am not convinced that this plugin should be the one to handle this feature. I believe that documentation pages deserve proper social images and this is something that should be handled at the Starlight level. If this was the case, this plugin and blog posts would get social images for free.

Until this is something properly implemented in Starlight (I think Chris had some idea to explore), any method to add social images to Starlight documentation pages would also work for blog posts as well, e.g. generating them with astro-og-canvas as described in this guide (that's the approach used by Astro Docs) or even directly linking to them using the frontmatter head field.