File tree Expand file tree Collapse file tree 4 files changed +20
-14
lines changed
content/docs/style-guide/fixtures Expand file tree Collapse file tree 4 files changed +20
-14
lines changed Original file line number Diff line number Diff line change 88
99import { Tabs , TabItem } from " ~/components" ;
1010
11- The HTML generated by this file is used as a test fixture for our Markdown generation.
11+ The HTML generated by this file is used as a test fixture for our Markdown generation:
1212
1313<Tabs >
1414 <TabItem label = " mdx" >
Original file line number Diff line number Diff line change 11import { parse } from "node-html-parser" ;
22import { process } from "../util/rehype" ;
33
4+ import YAML from "yaml" ;
5+
46import rehypeParse from "rehype-parse" ;
57import rehypeBaseUrl from "../plugins/rehype/base-url" ;
68import rehypeFilterElements from "../plugins/rehype/filter-elements" ;
@@ -39,14 +41,17 @@ export async function htmlToMarkdown(
3941
4042 const withFrontmatter = [
4143 "---" ,
42- `title: ${ title } ` ,
43- description ? `description: ${ description } ` : [ ] ,
44- lastUpdated ? `lastUpdated: ${ lastUpdated } ` : [ ] ,
45- chatbotDeprioritize ? `chatbotDeprioritize: ${ chatbotDeprioritize } ` : [ ] ,
46- tags ? `tags: ${ tags } ` : [ ] ,
47- `source_url:` ,
48- ` html: ${ url . replace ( "index.md" , "" ) } ` ,
49- ` md: ${ url } ` ,
44+ YAML . stringify ( {
45+ title,
46+ description,
47+ lastUpdated,
48+ chatbotDeprioritize : Boolean ( chatbotDeprioritize ) ,
49+ tags,
50+ source_url : {
51+ html : url . replace ( "index.md" , "" ) ,
52+ md : url ,
53+ } ,
54+ } ) . trim ( ) ,
5055 "---\n" ,
5156 markdown ,
5257 ]
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const workspace = defineWorkspace([
1212 optimizer : {
1313 ssr : {
1414 enabled : true ,
15- include : [ "node-html-parser" ] ,
15+ include : [ "node-html-parser" , "yaml" ] ,
1616 } ,
1717 } ,
1818 } ,
Original file line number Diff line number Diff line change @@ -254,15 +254,16 @@ describe("Cloudflare Docs", () => {
254254 expect ( text ) . toMatchInlineSnapshot ( `
255255 "---
256256 title: Markdown · Cloudflare Style Guide
257- description: The HTML generated by this file is used as a test fixture for our Markdown generation.
257+ description: "The HTML generated by this file is used as a test fixture for our
258+ Markdown generation:"
258259 lastUpdated: 2025-01-01T00:00:00.000Z
259260 chatbotDeprioritize: true
260261 source_url:
261262 html: http://fakehost/style-guide/fixtures/markdown/
262263 md: http://fakehost/style-guide/fixtures/markdown/index.md
263264 ---
264265
265- The HTML generated by this file is used as a test fixture for our Markdown generation.
266+ The HTML generated by this file is used as a test fixture for our Markdown generation:
266267
267268 * mdx
268269
@@ -353,10 +354,10 @@ describe("Cloudflare Docs", () => {
353354 ?. attributes . content ;
354355
355356 expect ( desc ) . toMatchInlineSnapshot (
356- `"The HTML generated by this file is used as a test fixture for our Markdown generation. "` ,
357+ `"The HTML generated by this file is used as a test fixture for our Markdown generation: "` ,
357358 ) ;
358359 expect ( og ) . toMatchInlineSnapshot (
359- `"The HTML generated by this file is used as a test fixture for our Markdown generation. "` ,
360+ `"The HTML generated by this file is used as a test fixture for our Markdown generation: "` ,
360361 ) ;
361362 } ) ;
362363 } ) ;
You can’t perform that action at this time.
0 commit comments