Skip to content

Commit 0563e0f

Browse files
committed
feat: rm onefile page
1 parent 1dc4ed5 commit 0563e0f

File tree

5 files changed

+690
-354
lines changed

5 files changed

+690
-354
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@
4646
"react-i18next": "^14.1.2",
4747
"react-icons": "^4.3.1",
4848
"react-infinite-scroll-hook": "^4.0.3",
49-
"react-markdown": "^8.0.3",
49+
"react-markdown": "^9.0.1",
5050
"react-syntax-highlighter": "^15.5.0",
51+
"remark-gfm": "^4.0.0",
5152
"sortablejs": "^1.15.0",
5253
"swr": "^1.3.0",
5354
"tailwind-merge": "^1.2.1"

src/components/buttons/RankButton.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const RankButton = ({ t, type = '' }: RankButtonProps) => {
1919
{ key: '/periodical', value: t('header.periodical') },
2020
{ key: '/report/tiobe', value: t('header.rank') },
2121
{ key: '/article', value: t('header.article') },
22-
{ key: '/onefile', value: 'OneFile' },
2322
];
2423

2524
const onChange = async (opt: option) => {

src/components/layout/Header.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ const Header = () => {
7676
<li className={liClassName('/article')}>
7777
<HeaderBtn pathname='/article'>{t('header.article')}</HeaderBtn>
7878
</li>
79-
<li className={liClassName('/onefile')}>
80-
<HeaderBtn pathname='/onefile'>OneFile</HeaderBtn>
81-
</li>
8279
{/* 移动端显示的登录按钮和头像 */}
8380
<li className='block md:hidden'>
8481
{!isLogin ? <LoginButton t={t} /> : <AvatarWithDropdown t={t} />}

src/components/mdRender/MDRender.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ReactMarkdown from 'react-markdown';
22
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
33
import { atomDark, vs } from 'react-syntax-highlighter/dist/cjs/styles/prism';
4+
import remarkGfm from 'remark-gfm';
45

56
import clsxm from '@/lib/clsxm';
67
import { useLoginContext } from '@/hooks/useLoginContext';
@@ -32,7 +33,7 @@ export const CodeRender = ({ code, lanuage }: CodeProps) => {
3233
}
3334
} else {
3435
return (
35-
<span className='rounded-sm bg-gray-100 px-1.5 py-0.5 text-sm font-medium dark:bg-gray-600'>
36+
<span className='rounded-sm bg-gray-100 px-1.5 py-0.5 text-sm font-medium dark:bg-gray-600'>
3637
{code}
3738
</span>
3839
);
@@ -47,8 +48,9 @@ export const MDRender = ({
4748
}: MDRenderProps) => {
4849
const { theme } = useLoginContext();
4950

50-
const getCode = (theme: string) => {
51+
const getComponents = (theme: string) => {
5152
return {
53+
// 代码块渲染
5254
code({ node: _node, inline, className, children, ...props }: any) {
5355
const match = /language-(\w+)/.exec(className || '') || 'shell';
5456
if (!inline && match) {
@@ -79,7 +81,7 @@ export const MDRender = ({
7981
} else {
8082
return (
8183
<span
82-
className='rounded-sm bg-gray-100 px-1.5 py-0.5 text-sm font-medium dark:bg-gray-600'
84+
className='rounded-sm bg-gray-100 px-1.5 py-0.5 text-sm font-medium dark:bg-gray-600'
8385
{...props}
8486
>
8587
{children}
@@ -92,7 +94,10 @@ export const MDRender = ({
9294

9395
return (
9496
<div className={clsxm('', className)} {...rest}>
95-
<ReactMarkdown components={getCode(theme)}>
97+
<ReactMarkdown
98+
remarkPlugins={[remarkGfm]}
99+
components={getComponents(theme)}
100+
>
96101
{mdString || children}
97102
</ReactMarkdown>
98103
</div>

0 commit comments

Comments
 (0)