-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: add support for shiki defaultColors
option
#11341
Feature: add support for shiki defaultColors
option
#11341
Conversation
🦋 Changeset detectedLatest commit: 29f056e The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/astro/test/fixtures/astro-markdown-shiki/default-color/astro.config.mjs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
Co-authored-by: Bjorn Lu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Awesome work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just placeholding for docs here!
Thanks @madcampos, we will need docs in order to get this into 4.12. Thanks! |
Sorry for the delay folks, here is the docs PR: withastro/docs#8722 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for providing the docs PR, @madcampos ! Based on that, here's an idea for the changeset message. For minor releases, we don't mind if they are a little longer since people will often (excitedly!) read them to learn about what's new. Let's take the opportunity to sell this a little bit, eh!
.changeset/cold-crabs-arrive.md
Outdated
'astro': minor | ||
--- | ||
|
||
Enable the "defaultColor" option from shiki |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable the "defaultColor" option from shiki | |
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 CSS variables and use your own colors. | |
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, | |
}, | |
}, | |
}); | |
``` | |
```js | |
--- | |
import { Code } from 'astro:components'; | |
--- | |
<Code code={`const useMyColors = true`} lang="js" defaultColor=false /> |
OK, thanks for waiting! I'm not sure whether all of this is entirely accurate, but this is the general style of message I'm thinking of here. So, using this as a model, can you make this accurate/appropriate? I think this would be a helpful way to introduce this new option!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion! I've added a couple small changes. I hope that is okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, and I just updated some grammar and it's great, thank you!
Co-authored-by: Sarah Rainsberger <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for docs!
Changes
This add support for for the
defaultColor
option from shiki. It exposes the option both to the internal highlighter and to astro's config.Resolves: #11238
Testing
Two unit tests were added to ensure the setting is respected.
Docs
I think a reference to shiki's docs will help. Will create a PR to add the doc reference soon.
/cc @withastro/maintainers-docs for feedback!
PS: Thanks to @0916dhkim and @ettavolt for the help with the code