diff --git a/src/article/data/articleAPIService.ts b/src/article/data/articleAPIService.ts index d61e3bd..cdb1589 100644 --- a/src/article/data/articleAPIService.ts +++ b/src/article/data/articleAPIService.ts @@ -9,13 +9,11 @@ const articleEndpoint = "/papers/" async function getArticle(id: string): Promise
{ try { - // await new Promise((res, _) => { - // setTimeout(() => res(null), 2000); - // }); const response = await integratorApiClient.get( // `https://run.mocky.io/v3/62cd4581-d864-4d46-b1d6-02b45b5d1994/${id}` // `https://jsonplaceholder.typicode.com/posts/${id}` - articleEndpoint + id + `https://run.mocky.io/v3/066be3d8-0568-439a-8b20-062deed49a97` + // articleEndpoint + id ); const dto = response.data; return create({ diff --git a/src/components/Markdown.tsx b/src/components/Markdown.tsx index e28c8f2..f8e05b7 100644 --- a/src/components/Markdown.tsx +++ b/src/components/Markdown.tsx @@ -1,5 +1,3 @@ -import React from "react"; - /* -------------------------------------------------------------------------- */ /* MarkDown */ /* -------------------------------------------------------------------------- */ @@ -18,33 +16,137 @@ import Heading from "./typography/Heading"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { dark } from "react-syntax-highlighter/dist/esm/styles/prism"; import Link from "./typography/Link"; -import { indexOf } from "lodash"; +import style from "react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark"; export type Props = { markdown: string; }; const Markdown = ({ markdown }: Props) => { - let newMarkdown = markdown.replace(/\n/g, " \n"); - return ( { - return ( - - {props.children} - - ); - }, + ul: ({ node, ...props }) => ( +
    + ), + + ol: ({ node, ...props }) => ( +
      + ), + + h1: ({ node, ...props }) => ( +

      + ), + + h2: ({ node, ...props }) => ( +

      + ), + + h3: ({ node, ...props }) => ( +

      + ), + + h4: ({ node, ...props }) => ( +

      + ), + + h5: ({ node, ...props }) => ( +

      + ), + + h6: ({ node, ...props }) => ( +

      + ), + p: Typography, + + a: ({ node, ...props }) => ( + + ), code({ node, inline, className, children, ...props }) { const match = /language-(\w+)/.exec(className || ""); diff --git a/src/components/fetchAnArticle/AnArticleBody.tsx b/src/components/fetchAnArticle/AnArticleBody.tsx index 0329981..8186ca3 100644 --- a/src/components/fetchAnArticle/AnArticleBody.tsx +++ b/src/components/fetchAnArticle/AnArticleBody.tsx @@ -12,6 +12,7 @@ import * as ArticlePart from "../../components/Article/Article"; import BaseLayout from "components/BaseLayout"; import Container from "components/Container"; import NotFound from "./NotFound"; +import Markdown from "components/Markdown"; const AnArticleBody = () => { const store = useArticleStore(); @@ -46,7 +47,12 @@ const AnArticleBody = () => { {article?.title} -
      {article?.content}
      + +
      + +
      )}