Skip to content

Commit

Permalink
fix: always compile mdx with sanitized markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
abernier committed Nov 29, 2024
1 parent d539205 commit 79d4abb
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/utils/docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,17 @@ async function _getDocs(

const boxes: string[] = []

// Sanitize markdown
let content = compiled.content
// Remove <!-- --> comments from frontMatter
.replace(FRONTMATTER_REGEX, '')
// Remove extraneous comments from post
.replace(COMMENT_REGEX, '')
// Remove inline link syntax
.replace(INLINE_LINK_REGEX, '$1')

await compileMDX({
source: compiled.content,
source: content,
options: {
mdxOptions: {
rehypePlugins: [
Expand All @@ -116,7 +125,8 @@ async function _getDocs(
boxes,
//
file,
compiled,
content,
frontmatter,
}
}),
)
Expand All @@ -135,7 +145,8 @@ async function _getDocs(
boxes,
// Passed from the 1st pass
file,
compiled,
content,
frontmatter,
}) => {
const relFilePath = file.substring(root.length) // "/getting-started/tutorials/store.mdx"

Expand All @@ -159,8 +170,6 @@ async function _getDocs(
// frontmatter
//

const frontmatter = compiled.data

const description: string = frontmatter.description ?? ''

const sourcecode: string = frontmatter.sourcecode ?? ''
Expand Down Expand Up @@ -191,15 +200,6 @@ async function _getDocs(
// } as Doc
// }

// Sanitize markdown
let content = compiled.content
// Remove <!-- --> comments from frontMatter
.replace(FRONTMATTER_REGEX, '')
// Remove extraneous comments from post
.replace(COMMENT_REGEX, '')
// Remove inline link syntax
.replace(INLINE_LINK_REGEX, '$1')

//
// inline images
//
Expand Down

0 comments on commit 79d4abb

Please sign in to comment.