Skip to content

Commit e79e377

Browse files
authored
Remove pre-shiki v0.14 theme names (#8169)
1 parent 15471e6 commit e79e377

File tree

6 files changed

+14
-80
lines changed

6 files changed

+14
-80
lines changed

.changeset/spicy-icons-live.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@astrojs/markdoc': minor
3+
'@astrojs/mdx': minor
4+
'@astrojs/markdown-remark': major
5+
'astro': major
6+
---
7+
8+
Remove pre-shiki v0.14 theme names for compatibility. Please rename to the new theme names to migrate:
9+
10+
- `material-darker` -> `material-theme-darker`
11+
- `material-default` -> `material-theme`
12+
- `material-lighter` -> `material-theme-lighter`
13+
- `material-ocean` -> `material-theme-ocean`
14+
- `material-palenight` -> `material-theme-palenight`

packages/astro/components/shiki-themes.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,4 @@ export const themes = {
3434
'solarized-light': () => import('shiki/themes/solarized-light.json').then(mod => mod.default),
3535
'vitesse-dark': () => import('shiki/themes/vitesse-dark.json').then(mod => mod.default),
3636
'vitesse-light': () => import('shiki/themes/vitesse-light.json').then(mod => mod.default),
37-
// old theme names for compat
38-
'material-darker': () => import('shiki/themes/material-theme-darker').then(mod => mod.default),
39-
'material-default': () => import('shiki/themes/material-theme').then(mod => mod.default),
40-
'material-lighter': () => import('shiki/themes/material-theme-lighter').then(mod => mod.default),
41-
'material-ocean': () => import('shiki/themes/material-theme-ocean').then(mod => mod.default),
42-
'material-palenight': () => import('shiki/themes/material-theme-palenight').then(mod => mod.default),
4337
};

packages/astro/scripts/shiki-gen-themes.mjs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ const themeImports = dir.map((f) => {
88
return [f.slice(0, f.indexOf('.json')), toThemeImport(f)];
99
});
1010

11-
// Map of old theme names to new names to preserve compatibility when we upgrade shiki
12-
const compatThemes = {
13-
'material-darker': 'material-theme-darker',
14-
'material-default': 'material-theme',
15-
'material-lighter': 'material-theme-lighter',
16-
'material-ocean': 'material-theme-ocean',
17-
'material-palenight': 'material-theme-palenight',
18-
};
19-
2011
let code = `\
2112
/**
2213
* This file is prebuilt from packages/astro/scripts/shiki-gen-themes.mjs
@@ -29,10 +20,6 @@ export const themes = {`;
2920
for (const [key, imp] of themeImports) {
3021
code += `\n\t'${key}': () => ${imp},`;
3122
}
32-
code += `\n\t// old theme names for compat`;
33-
for (const oldName in compatThemes) {
34-
code += `\n\t'${oldName}': () => ${toThemeImport(compatThemes[oldName])},`;
35-
}
3623
code += '\n};';
3724

3825
// eslint-disable-next-line no-console

packages/integrations/markdoc/src/extensions/shiki.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,6 @@ import type * as shikiTypes from 'shiki';
55
import { getHighlighter } from 'shiki';
66
import type { AstroMarkdocConfig } from '../config.js';
77

8-
// Map of old theme names to new names to preserve compatibility when we upgrade shiki
9-
const compatThemes: Record<string, string> = {
10-
'material-darker': 'material-theme-darker',
11-
'material-default': 'material-theme',
12-
'material-lighter': 'material-theme-lighter',
13-
'material-ocean': 'material-theme-ocean',
14-
'material-palenight': 'material-theme-palenight',
15-
};
16-
17-
const normalizeTheme = (theme: string | shikiTypes.IShikiTheme) => {
18-
if (typeof theme === 'string') {
19-
return compatThemes[theme] || theme;
20-
} else if (compatThemes[theme.name]) {
21-
return { ...theme, name: compatThemes[theme.name] };
22-
} else {
23-
return theme;
24-
}
25-
};
26-
278
const ASTRO_COLOR_REPLACEMENTS = {
289
'#000001': 'var(--astro-code-color-text)',
2910
'#000002': 'var(--astro-code-color-background)',
@@ -53,8 +34,6 @@ export default async function shiki({
5334
theme = 'github-dark',
5435
wrap = false,
5536
}: ShikiConfig = {}): Promise<AstroMarkdocConfig> {
56-
theme = normalizeTheme(theme);
57-
5837
const cacheID: string = typeof theme === 'string' ? theme : theme.name;
5938
if (!highlighterCache.has(cacheID)) {
6039
highlighterCache.set(

packages/integrations/mdx/src/remark-shiki.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,7 @@ import { visit } from 'unist-util-visit';
1010
*/
1111
const highlighterCacheAsync = new Map<string, Promise<shiki.Highlighter>>();
1212

13-
// Map of old theme names to new names to preserve compatibility when we upgrade shiki
14-
const compatThemes: Record<string, string> = {
15-
'material-darker': 'material-theme-darker',
16-
'material-default': 'material-theme',
17-
'material-lighter': 'material-theme-lighter',
18-
'material-ocean': 'material-theme-ocean',
19-
'material-palenight': 'material-theme-palenight',
20-
};
21-
22-
const normalizeTheme = (theme: string | shiki.IShikiTheme) => {
23-
if (typeof theme === 'string') {
24-
return compatThemes[theme] || theme;
25-
} else if (compatThemes[theme.name]) {
26-
return { ...theme, name: compatThemes[theme.name] };
27-
} else {
28-
return theme;
29-
}
30-
};
31-
3213
const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }: ShikiConfig) => {
33-
theme = normalizeTheme(theme);
3414
const cacheID: string = typeof theme === 'string' ? theme : theme.name;
3515
let highlighterAsync = highlighterCacheAsync.get(cacheID);
3616
if (!highlighterAsync) {

packages/markdown/remark/src/remark-shiki.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,10 @@ import type { ShikiConfig } from './types.js';
1010
*/
1111
const highlighterCacheAsync = new Map<string, Promise<shiki.Highlighter>>();
1212

13-
// Map of old theme names to new names to preserve compatibility when we upgrade shiki
14-
const compatThemes: Record<string, string> = {
15-
'material-darker': 'material-theme-darker',
16-
'material-default': 'material-theme',
17-
'material-lighter': 'material-theme-lighter',
18-
'material-ocean': 'material-theme-ocean',
19-
'material-palenight': 'material-theme-palenight',
20-
};
21-
22-
const normalizeTheme = (theme: string | shiki.IShikiTheme) => {
23-
if (typeof theme === 'string') {
24-
return compatThemes[theme] || theme;
25-
} else if (compatThemes[theme.name]) {
26-
return { ...theme, name: compatThemes[theme.name] };
27-
} else {
28-
return theme;
29-
}
30-
};
31-
3213
const remarkShiki = async (
3314
{ langs = [], theme = 'github-dark', wrap = false }: ShikiConfig,
3415
scopedClassName?: string | null
3516
) => {
36-
theme = normalizeTheme(theme);
3717
const cacheID: string = typeof theme === 'string' ? theme : theme.name;
3818
let highlighterAsync = highlighterCacheAsync.get(cacheID);
3919
if (!highlighterAsync) {

0 commit comments

Comments
 (0)