-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add questions markdown formatter (#419)
* feat(app): add markdown formatter * Fix bug * feat(app): add prism theme * refactor(app): move mdx serializer to page * fix(app): storybook build error * refactor(app): disable prism plugin * refactor(app): change question content tag Co-authored-by: Michal Miszczyszyn <michal@mmiszy.pl>
- Loading branch information
1 parent
889bcd9
commit 1c97e9e
Showing
17 changed files
with
5,103 additions
and
8,951 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
apps/app/src/components/QuestionsList/QuestionItem/QuestionContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use client"; | ||
|
||
import { MDXRemote, MDXRemoteSerializeResult } from "next-mdx-remote"; | ||
|
||
import "prismjs/themes/prism-coy.min.css"; | ||
|
||
type QuestionContentProps = Readonly<{ | ||
source: MDXRemoteSerializeResult; | ||
}>; | ||
|
||
export const QuestionContent = ({ source }: QuestionContentProps) => { | ||
return ( | ||
<div className="prism-coy grow"> | ||
<MDXRemote {...source} /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// import remarkPrism from "remark-prism"; | ||
import { serialize } from "next-mdx-remote/serialize"; | ||
|
||
export const serializeSource = (source: string) => | ||
serialize(source, { | ||
mdxOptions: { | ||
// remarkPlugins: [remarkPrism], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { paths } from "openapi-types"; | ||
import { serializeSource } from "./markdown"; | ||
|
||
type APIQuestion = | ||
paths["/questions/{id}"]["get"]["responses"][200]["content"]["application/json"]["data"]; | ||
|
||
export const serializeQuestionToMarkdown = async ({ question, ...rest }: APIQuestion) => { | ||
const mdxContent = await serializeSource(question); | ||
return { mdxContent, ...rest }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.