-
-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JS support to
@astrojs/starlight/expressive-code
export (#1440)
- Loading branch information
1 parent
126b53b
commit 2ea1e88
Showing
7 changed files
with
71 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/starlight': patch | ||
--- | ||
|
||
Adds JS support to the `@astrojs/starlight/expressive-code` export to allow importing from non-TS environments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @file This file provides the types for Starlight's `@astrojs/starlight/expressive-code` export. | ||
*/ | ||
|
||
export * from 'astro-expressive-code'; | ||
|
||
import type { StarlightExpressiveCodeOptions } from './integrations/expressive-code'; | ||
|
||
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): StarlightExpressiveCodeOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @file This file is exported by Starlight as `@astrojs/starlight/expressive-code`. | ||
* | ||
* It is required by the `<Code>` component to access the same configuration preprocessor | ||
* function as the one used by the integration. | ||
* | ||
* It also provides access to all of the Expressive Code classes and functions without having | ||
* to install `astro-expressive-code` as an additional dependency into a user's project | ||
* (and thereby risiking version conflicts). | ||
* | ||
* Note: This file is intentionally not a TypeScript module to allow access to all exported | ||
* functionality even if TypeScript is not available, e.g. from the `ec.config.mjs` file | ||
* that does not get processed by Vite. | ||
*/ | ||
|
||
export * from 'astro-expressive-code'; | ||
|
||
// @ts-ignore - Types are provided by the separate `expressive-code.d.ts` file | ||
export function defineEcConfig(config) { | ||
return config; | ||
} |
70 changes: 0 additions & 70 deletions
70
packages/starlight/integrations/expressive-code/exports.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
/** | ||
* @file This file contains utility functions imported by the `<Code>` component. | ||
*/ | ||
|
||
export { useTranslations } from './utils/translations'; | ||
export { getStarlightEcConfigPreprocessor } from './integrations/expressive-code'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters