Skip to content

Commit

Permalink
feat: rm onefile page
Browse files Browse the repository at this point in the history
  • Loading branch information
521xueweihan committed Nov 15, 2024
1 parent 1dc4ed5 commit 0563e0f
Show file tree
Hide file tree
Showing 5 changed files with 690 additions and 354 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
"react-i18next": "^14.1.2",
"react-icons": "^4.3.1",
"react-infinite-scroll-hook": "^4.0.3",
"react-markdown": "^8.0.3",
"react-markdown": "^9.0.1",
"react-syntax-highlighter": "^15.5.0",
"remark-gfm": "^4.0.0",
"sortablejs": "^1.15.0",
"swr": "^1.3.0",
"tailwind-merge": "^1.2.1"
Expand Down
1 change: 0 additions & 1 deletion src/components/buttons/RankButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const RankButton = ({ t, type = '' }: RankButtonProps) => {
{ key: '/periodical', value: t('header.periodical') },
{ key: '/report/tiobe', value: t('header.rank') },
{ key: '/article', value: t('header.article') },
{ key: '/onefile', value: 'OneFile' },
];

const onChange = async (opt: option) => {
Expand Down
3 changes: 0 additions & 3 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ const Header = () => {
<li className={liClassName('/article')}>
<HeaderBtn pathname='/article'>{t('header.article')}</HeaderBtn>
</li>
<li className={liClassName('/onefile')}>
<HeaderBtn pathname='/onefile'>OneFile</HeaderBtn>
</li>
{/* 移动端显示的登录按钮和头像 */}
<li className='block md:hidden'>
{!isLogin ? <LoginButton t={t} /> : <AvatarWithDropdown t={t} />}
Expand Down
13 changes: 9 additions & 4 deletions src/components/mdRender/MDRender.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ReactMarkdown from 'react-markdown';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { atomDark, vs } from 'react-syntax-highlighter/dist/cjs/styles/prism';
import remarkGfm from 'remark-gfm';

import clsxm from '@/lib/clsxm';
import { useLoginContext } from '@/hooks/useLoginContext';
Expand Down Expand Up @@ -32,7 +33,7 @@ export const CodeRender = ({ code, lanuage }: CodeProps) => {
}
} else {
return (
<span className='rounded-sm bg-gray-100 px-1.5 py-0.5 text-sm font-medium dark:bg-gray-600'>
<span className='rounded-sm bg-gray-100 px-1.5 py-0.5 text-sm font-medium dark:bg-gray-600'>
{code}
</span>
);
Expand All @@ -47,8 +48,9 @@ export const MDRender = ({
}: MDRenderProps) => {
const { theme } = useLoginContext();

const getCode = (theme: string) => {
const getComponents = (theme: string) => {
return {
// 代码块渲染
code({ node: _node, inline, className, children, ...props }: any) {
const match = /language-(\w+)/.exec(className || '') || 'shell';
if (!inline && match) {
Expand Down Expand Up @@ -79,7 +81,7 @@ export const MDRender = ({
} else {
return (
<span
className='rounded-sm bg-gray-100 px-1.5 py-0.5 text-sm font-medium dark:bg-gray-600'
className='rounded-sm bg-gray-100 px-1.5 py-0.5 text-sm font-medium dark:bg-gray-600'
{...props}
>
{children}
Expand All @@ -92,7 +94,10 @@ export const MDRender = ({

return (
<div className={clsxm('', className)} {...rest}>
<ReactMarkdown components={getCode(theme)}>
<ReactMarkdown
remarkPlugins={[remarkGfm]}
components={getComponents(theme)}
>
{mdString || children}
</ReactMarkdown>
</div>
Expand Down
Loading

0 comments on commit 0563e0f

Please sign in to comment.