I'm making a NextJs Blog, and I have to render my markdown in a dynamic page. CSSReset is being used in my app, and as a consequence, markdown is not being displayed correctly. Can someone help me out on this??
my ThemeContainer
0 import React from "react";
1
2 import {
3 ThemeProvider as ChakraThemeProvider,
4 ColorModeProvider,
5 CSSReset,
6 } from "@chakra-ui/core";
7
8 import { ThemeProvider as EmotionThemeProvider } from "emotion-theming";
9 import theme from "../styles/theme";
10
11 export const ThemeContainer = ({ children }) => {
12 return (
13 <ChakraThemeProvider theme={theme}>
14 <ColorModeProvider value={"light"}>
15 <EmotionThemeProvider theme={theme}>
16 <CSSReset />
17 {children}
18 </EmotionThemeProvider>
19 </ColorModeProvider>
20 </ChakraThemeProvider>
21 );
22 };
My markdown file
10 const Post = (postData: Post) => {
+ 11 const content = hydrate(postData.source);
+ 12
+ 13 console.log(content);
_ 14
15 return (
~ 16 <Flex w="full" overflowY="hidden">
~ 17 <div>{content}</div>
~ 18 </Flex>
19 );
20 };
21
22 export default Post;
I haven't done styling because I want to know how to solve this problem I'm having, so I left just a small component rendering the content
Should I try to fork this CSSReset and remove the styles that are making it happen??
I had the same issue a while ago. I wouldn't recommend using ChakraUI for Markdown because it needs to reset all CSS styles which results in this issue, but If you have a hybrid app with both static and dynamic (non-markdown) sites and you only want to use ChakraUI with its CSSReset on your dynamic sites, then you can modify your _app, or ThemeContainer in this case, as following to prevent the CSSReset from being applied to your Markdown sites:
Let's say you have dynamic pages like x.com/[slug] and static pages like x.com/blog/[slug]
This will prevent the CSSReset Component from being rendered on your static pages (if their path includes /blog/) but ChakraUI will still work fine on any other paths.
But again, ChakraUI isn't a good solution to style Markdown since it requires CSSReset to work properly.
This solution worked for me (inside the _app.js file).