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

Add new <Code> component, to succeed <Prism> #1208

Merged
merged 8 commits into from
Sep 3, 2021
Merged

Conversation

FredKSchott
Copy link
Member

@FredKSchott FredKSchott commented Aug 23, 2021

Changes

  • Adds a new <Code> component, similar to <Prism>
  • Powered internally by shiki
  • RFC: 💡 RFC: Replace Prism with Shiki #1212
  • Bonus: Reimplements Debug component to use Code internally, removing the problem of CSS getting added to the page incorrectly! Moves Debug back to import {Debug} from 'astro/components'; with a nice backwards-compat deprecation message for anyone still using the old import URL.

Testing

  • Tests added.

Docs

  • Docs updated.

@FredKSchott FredKSchott requested a review from a team as a code owner August 23, 2021 23:35
@changeset-bot
Copy link

changeset-bot bot commented Aug 23, 2021

🦋 Changeset detected

Latest commit: 2f0c73c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro Patch

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

@vercel
Copy link

vercel bot commented Aug 23, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

astro-www – ./www

🔍 Inspect: https://vercel.com/pikapkg/astro-www/ELGi2hZ3W19nd1b9Vb4jYLvrt7tX
✅ Preview: https://astro-www-git-new-code-component-pikapkg.vercel.app

astro-docs – ./docs

🔍 Inspect: https://vercel.com/pikapkg/astro-docs/6n452e1sTKAHGSuQ4TaMKaDpVQQy
✅ Preview: https://astro-docs-git-new-code-component-pikapkg.vercel.app

@jasikpark
Copy link
Contributor

Could you add a link to the Shiki docs, especially the dark theme docs?

Copy link
Contributor

@jasikpark jasikpark left a comment

Choose a reason for hiding this comment

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

Left a comment, otherwise looks pretty great!

@jasikpark
Copy link
Contributor

I want to get the docs site setup with <Code> asap.. would that be via something like remark-shiki?

I think @natemoo-re built a theme for VSCode that we could pull in!

@matthewp
Copy link
Contributor

matthewp commented Sep 1, 2021

Just a note that this PR is for the Phase 1 section fo the RFC.

@FredKSchott
Copy link
Member Author

Talked with @matthewp and @natemoo-re today and they convinced me that the Debug change should get pulled out into a separate PR so as not to block the Phase 1 <Code> work that we set out to do.

Will remove and ALSO update shiki to latest which will get our tests passing!

@FredKSchott
Copy link
Member Author

Maybe the docs could show an example of using the debug and code components perhaps?

Docs already added, at builtin-components.md

@FredKSchott
Copy link
Member Author

Fixed the code overflow by default problem and added a new wrap prop to the component which lets you control overflow yourself.

<Code> // Default. overflow-x: auto;
<Code wrap={false}> // overflow-x: auto;
<Code wrap>  // Default: word wrap.
<Code wrap={null}> // no overflow control added. Will most likely overflow.

@FredKSchott FredKSchott requested a review from matthewp September 2, 2021 19:12
@FredKSchott FredKSchott dismissed jasikpark’s stale review September 2, 2021 19:16

bug? re-requested review

@jasikpark
Copy link
Contributor

Maybe the docs could show an example of using the debug and code components perhaps?

Docs already added, at builtin-components.md

I forgot to add wanting to show the outputted component w/in the page! both the source & the end result!

## `<Code />`

```astro
---
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be really cool to make use of https://github.com/unlight/remark-sources so that we can provide the rendered version of this code example inline with the component!

SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* add code component

* Update packages/astro/components/Debug.astro

Co-authored-by: Caleb Jasik <calebjasik@jasik.xyz>

* Update packages/astro/components/Debug.astro

Co-authored-by: Caleb Jasik <calebjasik@jasik.xyz>

* fix format in debug component

* remove Debug changes

* add wrap support

* add props docs

* update default theme

Co-authored-by: Peter Singh <drgaud@hotmail.com>
Co-authored-by: Caleb Jasik <calebjasik@jasik.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants