Site-wide annoucement banner
#1535
Replies: 1 comment 1 reply
-
Hi @wkillerud! Thanks for the feedback. One quick workaround: you can provide default frontmatter values by extending the // src/content/config.ts
import { defineCollection, z } from 'astro:content';
import { docsSchema } from '@astrojs/starlight/schema';
export const collections = {
docs: defineCollection({
schema: docsSchema({
extend: z.object({
banner: z.object({ content: z.string() }).default({
content:
'This documentation is in beta, and we’re looking for feedback. See how <a href="#">you can contribute</a> 🌟',
}),
}),
}),
}),
}; This will then apply to all pages that don’t have their own When building the banner feature we did initially consider building it as a top-level rather than page-level feature but had a couple of reservations:
I still think it could be nice to support the dismissible site-wide banner pattern, but wanted to share some of the reasons we didn’t yet and things we’d want to solve if we were to do this. |
Beta Was this translation helpful? Give feedback.
-
What version of
starlight
are you using?0.19.0
What is your idea?
The banner frontmatter, but configured in one location to set the banner for all pages.
Why is this feature necessary?
I'm building a new docsite using Starlight, and thought I would add this banner to set expectations and maybe nudge contributors to provide feedback or changes:
I can add the banner to all pages (since folks can land on any page), but that got me looking for a central location to add it instead.
I found a serviceable workaround using a component override for MarkdownContent, but it doesn't look quite as nice rendered as part of the main contents.
I imagine a config in
starlight()
defaultBanner
, or something along those lines. To opt out individual pages, maybe set the banner frontmatter content to an empty string?Do you have examples of this feature in other projects?
No response
Participation
Beta Was this translation helpful? Give feedback.
All reactions