Skip to content
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

Merged
merged 12 commits into from
Jul 17, 2024

Conversation

madcampos
Copy link
Contributor

@madcampos madcampos commented Jun 26, 2024

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

Copy link

changeset-bot bot commented Jun 26, 2024

🦋 Changeset detected

Latest 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

@github-actions github-actions bot added feat: markdown Related to Markdown (scope) pkg: astro Related to the core `astro` package (scope) labels Jun 26, 2024
@bluwy bluwy added the semver: minor Change triggers a `minor` release label Jun 26, 2024
@bluwy bluwy added this to the 4.12.0 milestone Jun 26, 2024
Copy link
Contributor

@github-actions github-actions bot left a 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.

@madcampos madcampos requested a review from bluwy June 26, 2024 23:58
@madcampos madcampos requested a review from bluwy June 27, 2024 05:27
Copy link
Member

@bluwy bluwy left a 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!

Copy link
Member

@sarah11918 sarah11918 left a 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!

.changeset/cold-crabs-arrive.md Outdated Show resolved Hide resolved
@matthewp
Copy link
Contributor

matthewp commented Jul 3, 2024

Thanks @madcampos, we will need docs in order to get this into 4.12. Thanks!

@madcampos
Copy link
Contributor Author

Sorry for the delay folks, here is the docs PR: withastro/docs#8722

Copy link
Member

@sarah11918 sarah11918 left a 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!

'astro': minor
---

Enable the "defaultColor" option from shiki
Copy link
Member

@sarah11918 sarah11918 Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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!

Copy link
Contributor Author

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

Copy link
Member

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!

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for docs!

This was referenced Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: markdown Related to Markdown (scope) pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown configuration for shiki doesn't accept defaultColor: false
4 participants