File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,15 @@ async function load(source) {
119
119
}
120
120
121
121
this . addContextDependency ( schemaDir ) ;
122
+
123
+ const nextjsExports = [
124
+ 'metadata' ,
125
+ 'revalidate' ,
126
+ ]
127
+ const nextjsExportsCode = nextjsExports
128
+ . map ( ( name ) => `export const ${ name } = frontmatter.nextjs?.${ name } ;` )
129
+ . join ( '\n' )
130
+
122
131
const result = `import React from 'react';
123
132
import yaml from 'js-yaml';
124
133
// renderers is imported separately so Markdoc isn't sent to the client
206
215
};
207
216
}`
208
217
}
209
-
218
+ ${ appDir ? nextjsExportsCode : '' }
210
219
export default${ appDir ? ' async' : '' } function MarkdocComponent(props) {
211
220
const markdoc = ${ appDir ? 'await getMarkdocData()' : 'props.markdoc' } ;
212
221
// Only execute HMR code in development
Original file line number Diff line number Diff line change @@ -169,7 +169,14 @@ async function getMarkdocData(context = {}) {
169
169
}
170
170
171
171
172
-
172
+ export const dynamic = frontmatter.nextjs?.dynamic;
173
+ export const dynamicParams = frontmatter.nextjs?.dynamicParams;
174
+ export const fetchCache = frontmatter.nextjs?.fetchCache;
175
+ export const maxDuration = frontmatter.nextjs?.maxDuration;
176
+ export const metadata = frontmatter.nextjs?.metadata;
177
+ export const preferredRegion = frontmatter.nextjs?.preferredRegion;
178
+ export const revalidate = frontmatter.nextjs?.revalidate;
179
+ export const runtime = frontmatter.nextjs?.runtime;
173
180
export default async function MarkdocComponent(props) {
174
181
const markdoc = await getMarkdocData ();
175
182
// Only execute HMR code in development
Original file line number Diff line number Diff line change @@ -177,6 +177,15 @@ test('app router', async () => {
177
177
) ;
178
178
} ) ;
179
179
180
+ test ( 'app router metadata' , async ( ) => {
181
+ const output = await callLoader (
182
+ options ( { appDir : true } ) ,
183
+ source . replace ( '---' , '---\nmetadata:\n title: Metadata title' )
184
+ ) ;
185
+
186
+ expect ( output ) . toContain ( 'export const metadata = frontmatter.nextjs?.metadata;' )
187
+ } ) ;
188
+
180
189
test . each ( [
181
190
[ undefined , undefined ] ,
182
191
[ './schemas/folders' , 'markdoc1' ] ,
You can’t perform that action at this time.
0 commit comments