Skip to content

Commit 2b49314

Browse files
authored
refactor(runtime): split hooks into several files (#2454)
1 parent 72e72b1 commit 2b49314

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+422
-472
lines changed

packages/core/src/node/mdx/processor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,9 @@ async function compile(options: CompileOptions): Promise<string> {
9494
frontmatter,
9595
} as PageMeta;
9696

97-
const result = `const frontmatter = ${JSON.stringify(frontmatter)};
98-
${compileResult}
99-
MDXContent.__RSPRESS_PAGE_META = {};
97+
const result = `${compileResult}
10098
99+
MDXContent.__RSPRESS_PAGE_META = {};
101100
MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(
102101
normalizePath(path.relative(docDirectory, filepath)),
103102
)}"] = ${JSON.stringify(pageMeta)};

packages/core/src/node/mdx/rehypePlugins/__snapshots__/headerAnchor.test.ts.snap

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`rehypeHeadAnchor > basic 1`] = `
4-
"const frontmatter = {};
5-
/*prettier-ignore-start*/
4+
"/*prettier-ignore-start*/
65
/*prettier-ignore-end*/
76
import {Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
87
import {useMDXComponents as _provideComponents} from "@mdx-js/react";
@@ -112,15 +111,14 @@ export default function MDXContent(props = {}) {
112111
}) : _createMdxContent(props);
113112
}
114113
115-
MDXContent.__RSPRESS_PAGE_META = {};
116114
115+
MDXContent.__RSPRESS_PAGE_META = {};
117116
MDXContent.__RSPRESS_PAGE_META["index.mdx"] = {"toc":[{"id":"custom-id","text":"title 1","depth":2},{"id":"custom-id","text":"title 1","depth":2},{"id":"title-2","text":"title 2","depth":2},{"id":"title-2-1","text":"title 2","depth":2},{"id":"title-2-2","text":"\`title\` 2","depth":2},{"id":"title-2-3","text":"Title 2","depth":2},{"id":"title-2-4","text":"**title** 2","depth":2},{"id":"title-2-5","text":"*title* 2","depth":2}],"title":"Guide","headingTitle":"Guide","frontmatter":{}};
118117
"
119118
`;
120119

121120
exports[`rehypeHeadAnchor > should render inline code in title 1`] = `
122-
"const frontmatter = {};
123-
import {jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
121+
"import {jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
124122
import {useMDXComponents as _provideComponents} from "@mdx-js/react";
125123
function _createMdxContent(props) {
126124
const _components = {
@@ -155,15 +153,14 @@ export default function MDXContent(props = {}) {
155153
}) : _createMdxContent(props);
156154
}
157155
158-
MDXContent.__RSPRESS_PAGE_META = {};
159156
157+
MDXContent.__RSPRESS_PAGE_META = {};
160158
MDXContent.__RSPRESS_PAGE_META["inline-code.mdx"] = {"toc":[],"title":"Hello World \`inline code\`","headingTitle":"Hello World \`inline code\`","frontmatter":{}};
161159
"
162160
`;
163161

164162
exports[`rehypeHeadAnchor > should support custom id 1`] = `
165-
"const frontmatter = {};
166-
import {jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
163+
"import {jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
167164
import {useMDXComponents as _provideComponents} from "@mdx-js/react";
168165
function _createMdxContent(props) {
169166
const _components = {
@@ -198,15 +195,14 @@ export default function MDXContent(props = {}) {
198195
}) : _createMdxContent(props);
199196
}
200197
201-
MDXContent.__RSPRESS_PAGE_META = {};
202198
199+
MDXContent.__RSPRESS_PAGE_META = {};
203200
MDXContent.__RSPRESS_PAGE_META["inline-code.mdx"] = {"toc":[],"title":"Hello World \`inline code\`","headingTitle":"Hello World \`inline code\`","frontmatter":{}};
204201
"
205202
`;
206203

207204
exports[`rehypeHeadAnchor > should support mdx component with trim 1`] = `
208-
"const frontmatter = {};
209-
import {jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
205+
"import {jsx as _jsx, jsxs as _jsxs} from "react/jsx-runtime";
210206
import {useMDXComponents as _provideComponents} from "@mdx-js/react";
211207
function _createMdxContent(props) {
212208
const _components = {
@@ -244,8 +240,8 @@ function _missingMdxReference(id, component) {
244240
throw new Error("Expected " + (component ? "component" : "object") + " \`" + id + "\` to be defined: you likely forgot to import, pass, or provide it.");
245241
}
246242
247-
MDXContent.__RSPRESS_PAGE_META = {};
248243
244+
MDXContent.__RSPRESS_PAGE_META = {};
249245
MDXContent.__RSPRESS_PAGE_META["inline-code.mdx"] = {"toc":[],"title":"Hello World ","headingTitle":"Hello World ","frontmatter":{}};
250246
"
251247
`;

0 commit comments

Comments
 (0)