Skip to content

Commit

Permalink
Add Starlight types to defineEcConfig and export `StarlightExpressi…
Browse files Browse the repository at this point in the history
…veCodeOptions` (#1437)
  • Loading branch information
hippotastic authored Jan 29, 2024
1 parent 2a761f8 commit 655aed4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/calm-roses-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astrojs/starlight': patch
---

Adds Starlight-specific types to `defineEcConfig` function and exports `StarlightExpressiveCodeOptions`.

This provides Starlight types and IntelliSense support for your Expressive Code configuration options inside an `ec.config.mjs` file. See the [Expressive Code documentation](https://expressive-code.com/key-features/code-component/#using-an-ecconfigmjs-file) for more information.
32 changes: 32 additions & 0 deletions packages/starlight/integrations/expressive-code/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,36 @@

export * from 'astro-expressive-code';

import type { StarlightExpressiveCodeOptions } from './index';

export type { StarlightExpressiveCodeOptions };

/**
* A utility function that helps you define an Expressive Code configuration object. It is meant
* to be used inside the optional config file `ec.config.mjs` located in the root directory
* of your Starlight project, and its return value to be exported as the default export.
*
* Expressive Code will automatically detect this file and use the exported configuration object
* to override its own default settings.
*
* Using this function is recommended, but not required. It just passes through the given object,
* but it also provides type information for your editor's auto-completion and type checking.
*
* @example
* ```js
* // ec.config.mjs
* import { defineEcConfig } from '@astrojs/starlight/expressive-code'
*
* export default defineEcConfig({
* themes: ['starlight-dark', 'github-light'],
* styleOverrides: {
* borderRadius: '0.5rem',
* },
* })
* ```
*/
export function defineEcConfig(config: StarlightExpressiveCodeOptions) {
return config;
}

export { getStarlightEcConfigPreprocessor } from './index';

0 comments on commit 655aed4

Please sign in to comment.