Skip to content

Commit 0929ebd

Browse files
committed
feat; add code highlight for markdown
1 parent a3e01d7 commit 0929ebd

File tree

5 files changed

+45
-1
lines changed

5 files changed

+45
-1
lines changed

gatsby-config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import rehypeSlug from 'rehype-slug';
2+
import rehypePrism from '@mapbox/rehype-prism';
23

34
export default {
45
siteMetadata: {
@@ -25,6 +26,7 @@ export default {
2526
mdxOptions: {
2627
rehypePlugins: [
2728
rehypeSlug,
29+
rehypePrism,
2830
],
2931
},
3032
gatsbyRemarkPlugins: [

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"dependencies": {
1616
"@csstools/postcss-global-data": "^1.0.3",
1717
"@jetbrains/kotlin-web-site-ui": "^4.6.0",
18+
"@mapbox/rehype-prism": "^0.9.0",
1819
"@rescui/button": "^0.8.0",
1920
"@rescui/checkbox": "^0.4.10",
2021
"@rescui/focus-manager": "^0.1.3",
@@ -29,6 +30,7 @@
2930
"postcss-each": "^1.1.0",
3031
"postcss-mixins": "^9.0.4",
3132
"postcss-preset-env": "^8.1.0",
33+
"prism-themes": "^1.9.0",
3234
"react": "^18.2.0",
3335
"react-dom": "^18.2.0",
3436
"react-gif-player": "^0.4.2",

src/components/Markdown/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import cn from "classnames";
33
import {MDXProvider} from "@mdx-js/react";
44
import {LinkIcon} from "@rescui/icons";
55
import {useTextStyles} from "@jetbrains/kotlin-web-site-ui/out/components/typography";
6+
import "prism-themes/themes/prism-one-light.min.css";
67

78
import {useSiteMeta, useSiteURL} from "../../utlis/hooks";
89
import {Link} from "../Link";

src/components/Markdown/modern.module.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,25 @@
4141
}
4242
}
4343

44+
pre.code-block,
4445
.code-block {
4546
display: inline-block;
4647
box-sizing: border-box;
4748
padding: var(--ktl-box-block-l);
4849
overflow: auto;
4950
white-space: pre;
50-
background: rgba(25,25,28,.05);
51+
background: #f3f3f3;
5152
border-radius: 8px;
53+
border: 0 none transparent;
5254
max-width: 100%;
5355
}
5456

5557
.code-block > code {
5658
display: block;
59+
60+
background: #f3f3f3;
61+
font-family: "JetBrains Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
62+
line-height: 1.5;
5763
}
5864

5965
.tag-anchor {

yarn.lock

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,15 @@
19791979
resolved "https://registry.yarnpkg.com/@lmdb/lmdb-win32-x64/-/lmdb-win32-x64-2.5.3.tgz#c72e8b6faae31d925d23a6db0379cc3fe0216fdd"
19801980
integrity sha512-cK+Elf3RjEzrm3SerAhrFWL5oQAsZSJ/LmjL1joIpTfEP1etJJ9CTRvdaV6XLYAxaEkfdhk/9hOvHLbR9yIhCA==
19811981

1982+
"@mapbox/rehype-prism@^0.9.0":
1983+
version "0.9.0"
1984+
resolved "https://registry.yarnpkg.com/@mapbox/rehype-prism/-/rehype-prism-0.9.0.tgz#63d10bb2db2630a485477eba175e481f61c32ac9"
1985+
integrity sha512-ypmEaqzdrqSon5NJdPqTh79qmPK8ajAqIU9mdFhuWn3T4B/RT2nt3yH2JPcou1/Gx8DvSgJ+XP+fy60e8h3mpQ==
1986+
dependencies:
1987+
hast-util-to-string "^1.0.4"
1988+
refractor "^3.4.0"
1989+
unist-util-visit "^2.0.3"
1990+
19821991
"@mdx-js/mdx@^2.1.5":
19831992
version "2.3.0"
19841993
resolved "https://registry.yarnpkg.com/@mdx-js/mdx/-/mdx-2.3.0.tgz#d65d8c3c28f3f46bb0e7cb3bf7613b39980671a9"
@@ -7394,6 +7403,11 @@ hast-util-to-parse5@^6.0.0:
73947403
xtend "^4.0.0"
73957404
zwitch "^1.0.0"
73967405

7406+
hast-util-to-string@^1.0.4:
7407+
version "1.0.4"
7408+
resolved "https://registry.yarnpkg.com/hast-util-to-string/-/hast-util-to-string-1.0.4.tgz#9b24c114866bdb9478927d7e9c36a485ac728378"
7409+
integrity sha512-eK0MxRX47AV2eZ+Lyr18DCpQgodvaS3fAQO2+b9Two9F5HEoRPhiUMNzoXArMJfZi2yieFzUBMRl3HNJ3Jus3w==
7410+
73977411
hast-util-to-string@^2.0.0:
73987412
version "2.0.0"
73997413
resolved "https://registry.yarnpkg.com/hast-util-to-string/-/hast-util-to-string-2.0.0.tgz#b008b0a4ea472bf34dd390b7eea1018726ae152a"
@@ -10868,6 +10882,16 @@ pretty-error@^2.1.2:
1086810882
lodash "^4.17.20"
1086910883
renderkid "^2.0.4"
1087010884

10885+
prism-themes@^1.9.0:
10886+
version "1.9.0"
10887+
resolved "https://registry.yarnpkg.com/prism-themes/-/prism-themes-1.9.0.tgz#19c034f3205f1e28d75d89728e54ccd745f7e3dd"
10888+
integrity sha512-tX2AYsehKDw1EORwBps+WhBFKc2kxfoFpQAjxBndbZKr4fRmMkv47XN0BghC/K1qwodB1otbe4oF23vUTFDokw==
10889+
10890+
prismjs@~1.27.0:
10891+
version "1.27.0"
10892+
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.27.0.tgz#bb6ee3138a0b438a3653dd4d6ce0cc6510a45057"
10893+
integrity sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==
10894+
1087110895
probe-image-size@^7.2.3:
1087210896
version "7.2.3"
1087310897
resolved "https://registry.yarnpkg.com/probe-image-size/-/probe-image-size-7.2.3.tgz#d49c64be540ec8edea538f6f585f65a9b3ab4309"
@@ -11289,6 +11313,15 @@ reflect.ownkeys@^0.2.0:
1128911313
resolved "https://registry.yarnpkg.com/reflect.ownkeys/-/reflect.ownkeys-0.2.0.tgz#749aceec7f3fdf8b63f927a04809e90c5c0b3460"
1129011314
integrity sha512-qOLsBKHCpSOFKK1NUOCGC5VyeufB6lEsFe92AL2bhIJsacZS1qdoOZSbPk3MYKuT2cFlRDnulKXuuElIrMjGUg==
1129111315

11316+
refractor@^3.4.0:
11317+
version "3.6.0"
11318+
resolved "https://registry.yarnpkg.com/refractor/-/refractor-3.6.0.tgz#ac318f5a0715ead790fcfb0c71f4dd83d977935a"
11319+
integrity sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA==
11320+
dependencies:
11321+
hastscript "^6.0.0"
11322+
parse-entities "^2.0.0"
11323+
prismjs "~1.27.0"
11324+
1129211325
regenerate-unicode-properties@^10.0.1:
1129311326
version "10.0.1"
1129411327
resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz#7f442732aa7934a3740c779bb9b3340dccc1fb56"

0 commit comments

Comments
 (0)