Skip to content

Commit 5562b2f

Browse files
committed
Add demo files to bundler
1 parent fae9afe commit 5562b2f

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

packages/mdx/src/annotations.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ function Label({
7878
style?: React.CSSProperties
7979
theme?: any
8080
}) {
81-
console.log(data)
8281
const bg = ((theme as any).colors[
8382
"editor.lineHighlightBackground"
8483
] ||
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function MyTooltipAnnotation() {
2+
return "I'm a tooltip"
3+
}

packages/playground/src/page-data.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,36 @@ async function getDemoList() {
1111
.map(filename => filename.slice(0, -4))
1212
}
1313

14+
async function getFiles(demo) {
15+
let filenames = []
16+
try {
17+
filenames = await fs.promises.readdir(
18+
`./content/${demo}/`
19+
)
20+
} catch (e) {
21+
return undefined
22+
}
23+
24+
const files = {}
25+
for (const filename of filenames) {
26+
files[filename] = await fs.promises.readFile(
27+
`./content/${demo}/${filename}`,
28+
"utf8"
29+
)
30+
}
31+
32+
return files
33+
}
34+
1435
export async function toProps({ demo, theme }) {
1536
const mdxSource = await fs.promises.readFile(
1637
`./content/${demo}.mdx`,
1738
"utf8"
1839
)
1940

20-
const preCodeHike = await bundle(mdxSource, [
41+
const files = await getFiles(demo)
42+
43+
const preCodeHike = await bundle(mdxSource, files, [
2144
remarkShowTree,
2245
])
2346

@@ -27,12 +50,12 @@ export async function toProps({ demo, theme }) {
2750
`shiki/themes/${theme}.json`
2851
).then(module => module.default)
2952

30-
postCodeHike = await bundle(mdxSource, [
53+
postCodeHike = await bundle(mdxSource, files, [
3154
[remarkCodeHike, { theme: loadedTheme }],
3255
remarkShowTree,
3356
])
3457

35-
result = await bundle(mdxSource, [
58+
result = await bundle(mdxSource, files, [
3659
[remarkCodeHike, { theme: loadedTheme }],
3760
])
3861
} catch (e) {
@@ -70,8 +93,9 @@ export async function toProps({ demo, theme }) {
7093
}
7194
}
7295

73-
async function bundle(source, plugins) {
96+
async function bundle(source, files, plugins) {
7497
const { code } = await bundleMDX(source, {
98+
files,
7599
esbuildOptions(options) {
76100
options.minify = false
77101
options.platform = "node"

0 commit comments

Comments
 (0)