Skip to content

Commit b66971e

Browse files
authored
fix: use rehype-shikiji (#6054)
* fix: use rehype-shikiji * chore: webpack does not support .mjs by default * fix: support dockerfile format * fix: date changing on story every day * fix: add support to diff
1 parent 00726f9 commit b66971e

File tree

7 files changed

+173
-132
lines changed

7 files changed

+173
-132
lines changed

components/Common/BlogPostCard/index.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const Default: Story = {
1717
src: 'https://avatars.githubusercontent.com/u/',
1818
},
1919
],
20-
date: new Date(),
20+
date: new Date('17 October 2023'),
2121
},
2222
decorators: [
2323
Story => (

next.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ const nextConfig = {
3434
// as we already check it on the CI within each Pull Request
3535
// we also configure ESLint to run its lint checking on all files (next lint)
3636
eslint: { dirs: ['.'], ignoreDuringBuilds: true },
37+
// Next.js WebPack Bundler does not know how to handle `.mjs` files on `node_modules`
38+
// This is not an issue when using TurboPack as it uses SWC and it is ESM-only
39+
// Once we migrate to Next.js 14 we might be able to remove this
40+
webpack: function (config) {
41+
config.module.rules.push({
42+
test: /\.m?js$/,
43+
type: 'javascript/auto',
44+
resolve: { fullySpecified: false },
45+
});
46+
return config;
47+
},
3748
experimental: {
3849
// Some of our static pages from `getStaticProps` have a lot of data
3950
// since we pass the fully-compiled MDX page from `MDXRemote` through

next.mdx.mjs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import * as remarkHeadings from '@vcarl/remark-headings';
1212
import * as mdastAutoLink from 'mdast-util-gfm-autolink-literal';
1313
import * as mdastTable from 'mdast-util-gfm-table';
1414
import * as rehypeAutolinkHeadings from 'rehype-autolink-headings';
15-
import * as rehypePrettyCode from 'rehype-pretty-code';
1615
import * as rehypeRaw from 'rehype-raw';
16+
import * as rehypeShikiji from 'rehype-shikiji';
1717
import * as rehypeSlug from 'rehype-slug';
18-
import { getHighlighter } from 'shiki';
1918

20-
import { LANGUAGES, DEFAULT_THEME, DEFAULT_LANG } from './shiki.config.mjs';
19+
import { LANGUAGES, DEFAULT_THEME } from './shiki.config.mjs';
2120

2221
/**
2322
* This function is used to add individual `mdast` plugins to the unified/mdx
@@ -64,13 +63,8 @@ export function nextRehypePlugins(fileExtension) {
6463
],
6564
[
6665
// Syntax Highlighter for Code Blocks
67-
rehypePrettyCode.default,
68-
{
69-
theme: DEFAULT_THEME,
70-
defaultLang: DEFAULT_LANG,
71-
getHighlighter: options =>
72-
getHighlighter({ ...options, langs: LANGUAGES }),
73-
},
66+
rehypeShikiji.default,
67+
{ theme: DEFAULT_THEME, langs: LANGUAGES },
7468
],
7569
];
7670

package-lock.json

Lines changed: 133 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts:release-post": "cross-env NODE_NO_WARNINGS=1 node scripts/release-post/index.mjs",
2020
"scripts:generate-next-data": "cross-env NODE_NO_WARNINGS=1 node scripts/generate-next-data/index.mjs",
2121
"preserve": "npm run scripts:generate-next-data",
22-
"serve": "cross-env NODE_NO_WARNINGS=1 next dev --turbo",
22+
"serve": "cross-env NODE_NO_WARNINGS=1 next dev",
2323
"prebuild": "npm run scripts:generate-next-data",
2424
"build": "cross-env NODE_NO_WARNINGS=1 next build",
2525
"start": "cross-env NODE_NO_WARNINGS=1 next start",
@@ -73,12 +73,11 @@
7373
"react-dom": "^18.2.0",
7474
"react-intl": "~6.4.7",
7575
"rehype-autolink-headings": "~7.0.0",
76-
"rehype-pretty-code": "~0.10.1",
7776
"rehype-raw": "~7.0.0",
77+
"rehype-shikiji": "~0.6.10",
7878
"rehype-slug": "~6.0.0",
7979
"semver": "~7.5.4",
8080
"sharp": "0.32.6",
81-
"shiki": "npm:[email protected]",
8281
"tailwindcss": "^3.3.3",
8382
"turbo": "1.10.16",
8483
"typescript": "~5.2.2",

0 commit comments

Comments
 (0)