feat: replace Prism with Shiki and add support for light/dark themes #1146
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✨ New Code Block Themes with Shiki
This PR replaces the existing PrismJS setup with Shiki, enabling faster, more accurate, and theme-aware syntax highlighting with support for both light and dark modes.
🔍 Why Shiki?
Theme
object to load your own theme.⚙️ How to Configure
In
contentlayer.config.ts
, you can configure the default themes like this:You can directly use shiki built-in themes. you just need to replace light and dark values with fallowing.
🌗 Example: Light & Dark Themes
🔄 Update Summary
prism.css
import fromapp/blog/[...slug]/page.tsx
Pre.tsx
component in thecomponents/
folderMDXComponents.tsx
to use the customPre
component instead of the one from Plinyrelease-of-tailwind-nextjs-starter-blog-v2.0.mdx
post with a guide for Shiki theme usageprism.css
filecontentlayer.config.ts
to remove PrismJS and integrate the@shikijs/rehype
pluginpackage.json
to remove PrismJS packages and add the Shiki rehype packagetailwind.css
with:remark-code-title
(Mac-style title bar)I hope you like it.