Aller au contenu
Bienvenue dans le plugin starlight-announcement ! Commencer

Configuration

Ce contenu n’est pas encore disponible dans votre langue.

The starlight-announcement plugin accepts the following configuration options.

astro.config.mjs
import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
import starlightAnnouncement from 'starlight-announcement'
export default defineConfig({
integrations: [
starlight({
plugins: [
starlightAnnouncement({
displayMode: 'stack',
rotateInterval: 5000,
announcements: [
// Your announcements here
],
}),
],
title: 'My Docs',
}),
],
})
  • Type: boolean
  • Default: true

Controls whether announcements are displayed. Set to false to disable all announcements while keeping your configuration intact.

starlightAnnouncement({
enabled: false, // Disable announcements
announcements: [
// Config preserved but not shown
],
})
  • Type: 'stack' | 'first' | 'rotate'
  • Default: 'stack'

Controls how multiple active announcements are displayed. See Display Modes for details.

ModeBehavior
stackAll active announcements shown vertically (default)
firstOnly the first matching announcement is displayed
rotateCarousel - cycles through announcements on interval
starlightAnnouncement({
displayMode: 'first', // Only show one announcement at a time
})
  • Type: number
  • Default: 5000
  • Minimum: 500

Interval in milliseconds between announcement transitions when using rotate display mode.

starlightAnnouncement({
displayMode: 'rotate',
rotateInterval: 3000, // 3 seconds between transitions
})
  • Type: boolean
  • Default: true

When using rotate display mode with multiple announcements, shows dot indicators below the banner. Users can click dots to jump to specific announcements, and the indicator supports keyboard navigation with arrow keys.

starlightAnnouncement({
displayMode: 'rotate',
showRotateIndicator: true, // Show navigation dots (default)
// showRotateIndicator: false, // Hide navigation dots
})
  • Type: Announcement[]
  • Default: []

Array of announcement objects. Each announcement has the following properties:

PropertyTypeRequiredDefaultDescription
idstringYes-Unique identifier (used for dismissal persistence)
contentstring | Record<string, string>Yes-The announcement text (supports HTML and localization)
variantstringNo'note'Visual style: note, tip, caution, danger
dismissiblebooleanNotrueWhether users can dismiss the announcement
linkobjectNo-Optional CTA link with text (localizable) and href
startDatestringNo-ISO date when announcement becomes visible
endDatestringNo-ISO date when announcement stops being visible
showOnstring[]No['/**']Glob patterns for pages to show on
hideOnstring[]No[]Glob patterns for pages to hide from

See Announcement Options for detailed documentation of each property.

astro.config.mjs
import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
import starlightAnnouncement from 'starlight-announcement'
export default defineConfig({
integrations: [
starlight({
plugins: [
starlightAnnouncement({
displayMode: 'stack',
announcements: [
{
id: 'v3-migration',
content: 'v3.0 has breaking changes!',
variant: 'caution',
link: {
text: 'Migration Guide',
href: '/guides/v3-migration',
},
dismissible: true,
startDate: '2026-01-01',
endDate: '2026-02-01',
showOn: ['/**'],
hideOn: ['/api/**'],
},
{
id: 'welcome',
content: 'Welcome to our new documentation site!',
variant: 'tip',
showOn: ['/'],
},
],
}),
],
title: 'My Docs',
}),
],
})