@@ -21,6 +21,13 @@ import {
2121 createSchemaPageMD ,
2222 createTagPageMD ,
2323} from "./markdown" ;
24+ import {
25+ introMdTemplateDefault ,
26+ infoMdTemplateDefault ,
27+ tagMdTemplateDefault ,
28+ schemaMdTemplateDefault ,
29+ infoMdTemplateDefault ,
30+ } from "./markdown/templates" ;
2431import { processOpenapiFiles , readOpenapiFiles } from "./openapi" ;
2532import { OptionsSchema } from "./options" ;
2633import generateSidebarSlice from "./sidebars" ;
@@ -117,6 +124,7 @@ export default function pluginOpenAPIDocs(
117124 specPath,
118125 outputDir,
119126 template,
127+ templateGenerators,
120128 infoTemplate,
121129 tagTemplate,
122130 schemaTemplate,
@@ -198,108 +206,27 @@ export default function pluginOpenAPIDocs(
198206
199207 const mdTemplate = template
200208 ? fs . readFileSync ( template ) . toString ( )
201- : `---
202- id: {{{id}}}
203- title: "{{{title}}}"
204- description: "{{{frontMatter.description}}}"
205- {{^api}}
206- sidebar_label: Introduction
207- {{/api}}
208- {{#api}}
209- sidebar_label: "{{{title}}}"
210- {{/api}}
211- {{^api}}
212- sidebar_position: 0
213- {{/api}}
214- hide_title: true
215- {{#api}}
216- hide_table_of_contents: true
217- {{/api}}
218- {{#json}}
219- api: {{{json}}}
220- {{/json}}
221- {{#api.method}}
222- sidebar_class_name: "{{{api.method}}} api-method"
223- {{/api.method}}
224- {{#infoPath}}
225- info_path: {{{infoPath}}}
226- {{/infoPath}}
227- custom_edit_url: null
228- {{#frontMatter.proxy}}
229- proxy: {{{frontMatter.proxy}}}
230- {{/frontMatter.proxy}}
231- {{#frontMatter.hide_send_button}}
232- hide_send_button: true
233- {{/frontMatter.hide_send_button}}
234- {{#frontMatter.show_extensions}}
235- show_extensions: true
236- {{/frontMatter.show_extensions}}
237- {{#frontMatter.mask_credentials_disabled}}
238- mask_credentials: false
239- {{/frontMatter.mask_credentials_disabled}}
240- ---
241-
242- {{{markdown}}}
243- ` ;
209+ : templateGenerators ?. createIntroTemplateMD
210+ ? templateGenerators . createIntroTemplateMD ( )
211+ : introMdTemplateDefault ;
244212
245213 const infoMdTemplate = infoTemplate
246214 ? fs . readFileSync ( infoTemplate ) . toString ( )
247- : `---
248- id: {{{id}}}
249- title: "{{{title}}}"
250- description: "{{{frontMatter.description}}}"
251- sidebar_label: "{{{title}}}"
252- hide_title: true
253- custom_edit_url: null
254- ---
255-
256- {{{markdown}}}
257-
258- \`\`\`mdx-code-block
259- import DocCardList from '@theme/DocCardList';
260- import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
261-
262- <DocCardList items={useCurrentSidebarCategory().items}/>
263- \`\`\`
264- ` ;
215+ : templateGenerators ?. createInfoTemplateMD
216+ ? templateGenerators . createInfoTemplateMD ( )
217+ : infoMdTemplateDefault ;
265218
266219 const tagMdTemplate = tagTemplate
267220 ? fs . readFileSync ( tagTemplate ) . toString ( )
268- : `---
269- id: {{{id}}}
270- title: "{{{frontMatter.description}}}"
271- description: "{{{frontMatter.description}}}"
272- custom_edit_url: null
273- ---
274-
275- {{{markdown}}}
276-
277- \`\`\`mdx-code-block
278- import DocCardList from '@theme/DocCardList';
279- import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
280-
281- <DocCardList items={useCurrentSidebarCategory().items}/>
282- \`\`\`
283- ` ;
221+ : templateGenerators ?. createTagTemplateMD
222+ ? templateGenerators . createTagTemplateMD ( )
223+ : tagMdTemplateDefault ;
284224
285225 const schemaMdTemplate = schemaTemplate
286226 ? fs . readFileSync ( schemaTemplate ) . toString ( )
287- : `---
288- id: {{{id}}}
289- title: "{{{title}}}"
290- description: "{{{frontMatter.description}}}"
291- sidebar_label: "{{{title}}}"
292- hide_title: true
293- {{#schema}}
294- hide_table_of_contents: true
295- {{/schema}}
296- schema: true
297- sample: {{{frontMatter.sample}}}
298- custom_edit_url: null
299- ---
300-
301- {{{markdown}}}
302- ` ;
227+ : templateGenerators ?. createSchemaTemplateMD
228+ ? templateGenerators . createSchemaTemplateMD ( )
229+ : schemaMdTemplateDefault ;
303230
304231 const apiPageGenerator =
305232 markdownGenerators ?. createApiPageMD ?? createApiPageMD ;
0 commit comments