summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHippo2024-01-29 23:52:57 +0100
committerGitHub2024-01-29 23:52:57 +0100
commit655aed4840cae59e9abd64b4b585e60f1cfab209 (patch)
tree290ad22df5d029fb01e22d19108197866d2ec7ff
parent2a761f8fbcb559c86f0e9c7adcc31c93b27dea70 (diff)
downloadIT.starlight-655aed4840cae59e9abd64b4b585e60f1cfab209.tar.gz
IT.starlight-655aed4840cae59e9abd64b4b585e60f1cfab209.tar.bz2
IT.starlight-655aed4840cae59e9abd64b4b585e60f1cfab209.zip
Add Starlight types to `defineEcConfig` and export `StarlightExpressiveCodeOptions` (#1437)
-rw-r--r--.changeset/calm-roses-joke.md7
-rw-r--r--packages/starlight/integrations/expressive-code/exports.ts32
2 files changed, 39 insertions, 0 deletions
diff --git a/.changeset/calm-roses-joke.md b/.changeset/calm-roses-joke.md
new file mode 100644
index 00000000..b2f7f10a
--- /dev/null
+++ b/.changeset/calm-roses-joke.md
@@ -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.
diff --git a/packages/starlight/integrations/expressive-code/exports.ts b/packages/starlight/integrations/expressive-code/exports.ts
index e789b085..3616c08d 100644
--- a/packages/starlight/integrations/expressive-code/exports.ts
+++ b/packages/starlight/integrations/expressive-code/exports.ts
@@ -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';