-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add support for shiki
defaultColors
option (#11341)
* feat: add shiki option for default color * feat: propagate shiki option for default color to astro config * feat: add tests for default color * chore: add change set * fix: add complete type to shiki default color config * fix: remove unneeded heavy shiki theme from fixture * fix: add literals to schema validation Co-authored-by: Bjorn Lu <[email protected]> * Update .changeset/cold-crabs-arrive.md Co-authored-by: Sarah Rainsberger <[email protected]> * feat: improve changeset * grammar tweak --------- Co-authored-by: Bjorn Lu <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]>
- Loading branch information
1 parent
f4870e5
commit 49b5145
Showing
11 changed files
with
129 additions
and
0 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,32 @@ | ||
--- | ||
'@astrojs/markdown-remark': minor | ||
'astro': minor | ||
--- | ||
|
||
Adds support for [Shiki's `defaultColor` option](https://shiki.style/guide/dual-themes#without-default-color). | ||
|
||
This option allows you to override the values of a theme's inline style, adding only CSS variables to give you more flexibility in applying multiple color themes. | ||
|
||
Configure `defaultColor: false` in your Shiki config to apply throughout your site, or pass to Astro's built-in `<Code>` component to style an individual code block. | ||
|
||
```js title="astro.config.mjs" | ||
import { defineConfig } from 'astro/config'; | ||
export default defineConfig({ | ||
markdown: { | ||
shikiConfig: { | ||
themes: { | ||
light: 'github-light', | ||
dark: 'github-dark', | ||
}, | ||
defaultColor: false, | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
```astro | ||
--- | ||
import { Code } from 'astro:components'; | ||
--- | ||
<Code code={`const useMyColors = true`} lang="js" defaultColor={false} /> | ||
``` |
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
13 changes: 13 additions & 0 deletions
13
packages/astro/test/fixtures/astro-markdown-shiki/default-color/astro.config.mjs
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,13 @@ | ||
export default { | ||
markdown: { | ||
syntaxHighlight: 'shiki', | ||
shikiConfig: { | ||
theme: 'github-light', | ||
themes: { | ||
light: 'github-light', | ||
dark: 'github-light' | ||
}, | ||
defaultColor: false | ||
}, | ||
}, | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/astro-markdown-shiki/default-color/package.json
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,8 @@ | ||
{ | ||
"name": "@test/astro-markdown-skiki-default-color", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/astro/test/fixtures/astro-markdown-shiki/default-color/src/layouts/content.astro
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,10 @@ | ||
<html> | ||
<head> | ||
<!-- Head Stuff --> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<slot></slot> | ||
</div> | ||
</body> | ||
</html> |
24 changes: 24 additions & 0 deletions
24
packages/astro/test/fixtures/astro-markdown-shiki/default-color/src/pages/index.md
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,24 @@ | ||
--- | ||
layout: ../layouts/content.astro | ||
--- | ||
|
||
# Hello world | ||
|
||
```yaml | ||
apiVersion: v3 | ||
kind: Pod | ||
metadata: | ||
name: rss-site | ||
labels: | ||
app: web | ||
spec: | ||
containers: | ||
- name: front-end | ||
image: nginx | ||
ports: | ||
- containerPort: 80 | ||
- name: rss-reader | ||
image: nickchase/rss-php-nginx:v1 | ||
ports: | ||
- containerPort: 88 | ||
``` |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.