[go: nahoru, domu]

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 note about default color configuration for shiki #8722

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

madcampos
Copy link

Description (required)

Add a note about Shiki's defaultColor option that is exposed to Astro on withastro/astro#11341.

Related issues & labels (optional)

  • Suggested label: improve documentation

For Astro version: 4.12. See astro PR #11341.

Tagging @sarah11918 for visibility

Copy link
vercel bot commented Jul 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Jul 4, 2024 10:47pm

@astrobot-houston
Copy link
Contributor

Hello! Thank you for opening your first PR to Astro’s Docs! 🎉

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any broken links you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Vercel 🥳

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@astrobot-houston
Copy link
Contributor
astrobot-houston commented Jul 4, 2024

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

Locale File Note
en guides/markdown-content.mdx Source changed, localizations will be marked as outdated.
en reference/api-reference.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@sarah11918 sarah11918 added this to the 4.12.0 milestone Jul 4, 2024
@sarah11918 sarah11918 added add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" when approved by Sarah! labels Jul 4, 2024
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 this contribution @madcampos ! I think people will enjoy having even more control over their highlighting!

I committed an edit just to fit more in with how we're already documenting these Shiki config options, but I'd like you to confirm the sentence I added at the end. I'm assuming that the <Code /> component would just pull from one's config by default, but I realized we don't actually say so.

Looking forward to having you as a member of Team Docs when this feature is released! 🥳

This component provides syntax highlighting for code blocks at build time (no client-side JavaScript included). The component is powered internally by Shiki and it supports all popular [themes](https://shiki.style/themes) and [languages](https://shiki.style/languages). Plus, you can add your custom themes, languages, and [transformers](#transformers) by passing them to the `theme`, `lang`, and `transformers` attributes respectively.
This component provides syntax highlighting for code blocks at build time (no client-side JavaScript included). The component is powered internally by Shiki and it supports all popular [themes](https://shiki.style/themes) and [languages](https://shiki.style/languages). Plus, you can add your custom themes, languages, [transformers](#transformers), and [default color theme](https://shiki.style/guide/dual-themes#without-default-color) by passing them to the `theme`, `lang`, `transformers`, and `defaultColor` attributes respectively.

By default, this component will use the settings from your [Shiki configuration](/en/guides/markdown-content/#shiki-configuration).
Copy link
Member

Choose a reason for hiding this comment

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

Is this true? If so, I think it's helpful to add here!

Copy link
Author

Choose a reason for hiding this comment

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

I just tested and it seems that the <Code /> component does not inherit any configuration 😕

It think it is worth to point out that to avoid confusion.

Copy link
Member
@sarah11918 sarah11918 Jul 5, 2024

Choose a reason for hiding this comment

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

Interesting! So it doesn't even use the theme you've set or anything? I would have assumed that it would! (It's a better story to tell if it does!) I guess it's because it's a Markdown configuration, so it's only relevant when writing code in markdown blocks. I wonder how difficult that would be for us to add....

But yes, if it's not true, we won't say it! Thank you for testing!

Copy link
Author

Choose a reason for hiding this comment

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

No problem!

I think it would not be so hard to add. One workaround would be to import astro config and then pass the specific part as props to the Code component. Something like this:

On the config file, export the shiki config:

export const shikiConfig = {
  //...
};

// All the regular astro config...

Then on an astro file import the config and use it to pass props to the code component:

---
import { shikiConfig } from '../astro.config.ts';
---

<Code {...shikiConfig} />

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@sarah11918
Copy link
Member

Thanks @madcampos , this looks great, and I consider the docs ready to go for 4.12, which is scheduled to be released on July 18!

@sarah11918 sarah11918 added the Merge Queue Approved and ready to be merged (wait for feature release if also labelled M-O-R)! label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. Merge Queue Approved and ready to be merged (wait for feature release if also labelled M-O-R)! merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" when approved by Sarah!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants