forked from withastro/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate code blocks to Expressive Code (withastro#3644)
* Migrate code blocks to Expressive Code * Update astro-expressive-code * Update to astro-expressive-code v0.9.0 * Fix code blocks in RTL langs using Expressive Code * Update to latest version * Move theme file, fix Firefox hover issue
- Loading branch information
1 parent
d68fbb8
commit 5f3f8ee
Showing
18 changed files
with
205 additions
and
1,298 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import path from 'path'; | ||
import { astroExpressiveCode, ExpressiveCodeTheme, pluginFramesTexts } from 'astro-expressive-code'; | ||
import { theme } from './syntax-highlighting-theme'; | ||
import { translations } from '../src/i18n/util'; | ||
|
||
// Provide Expressive Code with texts from our translations | ||
Object.entries(translations).forEach(([locale, texts]) => { | ||
pluginFramesTexts.overrideTexts(locale, { | ||
terminalWindowFallbackTitle: texts['expressiveCode.terminalWindowFallbackTitle'], | ||
copyButtonTooltip: texts['expressiveCode.copyButtonTooltip'], | ||
copyButtonCopied: texts['expressiveCode.copyButtonCopied'], | ||
}); | ||
}); | ||
|
||
// Allow creation of a pre-configured Expressive Code integration that matches the Astro Docs theme | ||
export const astroDocsExpressiveCode = () => astroExpressiveCode({ | ||
theme: new ExpressiveCodeTheme(theme), | ||
styleOverrides: { | ||
codeBackground: 'var(--theme-code-bg)', | ||
borderColor: 'hsl(269deg 22% 25%)', | ||
scrollbarThumbColor: 'hsl(269deg 20% 90% / 0.25)', | ||
scrollbarThumbHoverColor: 'hsl(269deg 20% 90% / 0.5)', | ||
}, | ||
frames: { | ||
styleOverrides: { | ||
editorTabBarBackground: 'var(--theme-code-tabs)', | ||
editorActiveTabBackground: 'hsl(269deg 40% 65% / 0.15)', | ||
editorActiveTabBorderBottom: 'hsl(269deg 35% 55%)', | ||
editorTabBarBorderBottom: 'var(--theme-code-tabs)', | ||
|
||
terminalTitlebarBackground: 'var(--theme-code-tabs)', | ||
terminalTitlebarBorderBottom: 'transparent', | ||
terminalBackground: 'var(--theme-code-bg)', | ||
}, | ||
}, | ||
textMarkers: { | ||
styleOverrides: { | ||
defaultChroma: '55', | ||
}, | ||
}, | ||
getBlockLocale: ({ file }) => { | ||
// Path format: `src/content/docs/en/getting-started.mdx` | ||
// Part indices: 0 1 2 3 4 | ||
const pathParts = path.relative(file.cwd, file.path).split(/[\\/]/); | ||
return pathParts[3]; | ||
}, | ||
}); |
Oops, something went wrong.