-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checklist Failure (type="checkbox\") #23
Comments
It may have been sublte, the issue is it's rendering |
It looks like |
I'd second @wooorm's question, |
Unfortunately none of those methods allow for the use of all of the following:
For this reason, the site has two different methods to render Markdown:
Method 1Basically your codesandbox code, except render's usage is really: import MDXLayout from '../components/MDXLayout'
import { getAllDocs, getDocBySlug } from '../lib/docs'
import render from '../lib/markdown'
type Props = {
meta: any
content: string
}
const Doc = ({ meta, content }: Props) => {
return (
<MDXLayout meta={meta}>
{content}
</MDXLayout>
)
}
export async function getStaticProps({ params }: { params: { slug: string } }) {
const doc = getDocBySlug(params.slug)
const content = await render(doc.content || '')
return {
props: {
...doc,
content
}
}
}
export async function getStaticPaths() {
const docs = getAllDocs()
const allPaths: { params: any }[] = []
docs.forEach((doc) => {
allPaths.push({
params: {
slug: doc.slug
}
})
})
return {
paths: allPaths,
fallback: true
}
}
export default Doc import type { FC } from 'react'
import BaseLayout from './BaseLayout'
const MDXLayout: FC<{ children: string; menu: string; meta: any }> = ({
children,
meta: pageMeta
}) => {
const meta = {
title: 'Wiki',
description: '',
cardImage: '',
...pageMeta
}
return (
<BaseLayout
meta={meta}
>
<article dangerouslySetInnerHTML={{ __html: children }} />
</BaseLayout>
)
}
export default MDXLayout import { useRouter } from 'next/dist/client/router'
import Head from 'next/head'
import Link from 'next/link'
import { FC } from 'react'
const BaseLayout: FC<{ menu?: JSX.Element; meta: any }> = ({
children,
meta
}) => {
const router = useRouter()
return (
<>
<Head>
<title>{meta.title}</title>
</Head>
<div className="page">
<h1 style={{ paddingTop: 0 }}>{meta.title}</h1>
{children}
</div>
</>
) Method 2Specifically following this guide: https://css-tricks.com/responsible-markdown-in-next-js/ I have (though messy) dragged all the required code snippets out of my project into the codesandbox: https://codesandbox.io/s/dangerous-html-example-forked-zz7yl?file=/src/App.js Unfortunately I cannot reproduce this issue using this method either, which is beyond frustrating. Well, I couldn't figure out how to codesandbox a next app to test the server-side include, but the client-side method is shown above. If there's nothing obvious about these methods described above that's broken, I'll have to publish the app itself as minimal reproduction, which.. eww, I don't want you guys to have to sift through that. |
I found the culprit:Replace This might be an issue for them instead? (should I move this?) |
Both xdm and rehype-react allow for all of the above.
Could you share the versions of dependencies you are using locally?
Code Sandbox has a Next starter which may help https://codesandbox.io/s/admiring-leftpad-iywjj (or click "Create Sandbox", and search for "Next" in the template list) |
@ChristianMurphy Sorry about that, please see the message just above where I finally found the issue. Also, here are the package versions I am using (should all be latest): "dependencies": {
"@babel/core": "^7.15.0",
"@jsdevtools/rehype-toc": "^3.0.2",
"gray-matter": "^4.0.3",
"next": "^11.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"rehype-format": "^4.0.0",
"rehype-partials": "^1.0.6",
"rehype-preset-minify": "^6.0.0",
"rehype-raw": "^6.1.0",
"rehype-react": "^7.0.1",
"rehype-slug": "^5.0.0",
"rehype-stringify": "^9.0.2",
"remark-emoji": "^3.0.1",
"remark-footnotes": "^4.0.1",
"remark-gfm": "^2.0.0",
"remark-parse": "^10.0.0",
"remark-rehype": "^9.0.0",
"remark-wiki-link": "^1.0.4",
"styled-components": "^5.3.1",
"unified": "^10.1.0"
},
"devDependencies": {
"@types/react": "^17.0.19",
"@types/styled-components": "^5.1.13",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"babel-plugin-styled-components": "^1.13.2",
"eslint": "^7.32.0",
"eslint-config-next": "^11.1.2",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "^7.25.1",
"prettier": "^2.3.2",
"prettier-eslint": "^13.0.0",
"typescript": "^4.4.2"
} Specifically: https://github.com/rehypejs/rehype-minify/tree/main/packages/rehype-preset-minify |
I'm not sure it is. closeSelfClosing: true it switches between a checkbox and text box, it seems like it may be related to the |
Why are you setting It’s a bug in |
Initial checklist
Affected packages and versions
rehype-format: ^4.0.0, rehype-raw: ^6.1.0, rehype-stringify: ^9.0.2, remark-gfm: ^2.0.0, remark-parse: ^10.0.0, remark-rehype: ^9.0.0, unified: ^10.1.0
Link to runnable example
No response
Steps to reproduce
Input Markdown
Library Method
Usage
Expected behavior
Actual behavior
Runtime
Node v16
Package manager
yarn v2
OS
Linux
Build and bundle tools
Next.js
The text was updated successfully, but these errors were encountered: