Skip to content

Commit

Permalink
Merge pull request #149 from relative-ci/update-repo-details
Browse files Browse the repository at this point in the history
refactor: Extract Markdown component
  • Loading branch information
vio authored Dec 19, 2024
2 parents 3ab7d0f + 3878bbf commit f58e1f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/components/markdown.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';
import ReactMarkdown from 'react-markdown';

export const Markdown = ({ source }) => <ReactMarkdown>{source}</ReactMarkdown>;
10 changes: 3 additions & 7 deletions src/components/repo-details.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React, { useEffect, useState } from 'react';
import useSWR from 'swr';
import { Alert, Divider, Spin, Typography } from 'antd';
import ReactMarkdown from 'react-markdown';
import { Alert, Divider, Spin } from 'antd';

import { Repo } from './repo';
import { Markdown } from './markdown';
import { fetcher } from '../utils';

const { Title } = Typography;

const Meta = ({ owner, repo }) => {
const { data, error } = useSWR(`/repos/${owner}/${repo}`, fetcher);

Expand Down Expand Up @@ -46,9 +44,7 @@ const ReadMe = ({ owner, repo }) => {
return <Spin />;
}

return (
<ReactMarkdown>{markdown}</ReactMarkdown>
);
return <Markdown source={markdown} />;
}

export const RepoDetails = (props) => {
Expand Down
5 changes: 5 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export default defineConfig((env) => ({
assetFileNames: 'assets/[name].[hash][extname]',
chunkFileNames: 'assets/[name].[hash].js',
entryFileNames: 'assets/[name].[hash].js',
manualChunks(id) {
if (id.includes('react-markdown')) {
return 'react-markdown';
}
},
},
},
},
Expand Down

0 comments on commit f58e1f0

Please sign in to comment.