diff --git a/src/components/PostCard.tsx b/src/components/PostCard.tsx index d1d5c5e..81fac5f 100644 --- a/src/components/PostCard.tsx +++ b/src/components/PostCard.tsx @@ -5,15 +5,18 @@ import { } from '@ant-design/icons'; import { Card, Tag } from 'antd'; import dayjs from 'dayjs'; +import { useLocation } from 'react-router-dom'; import type { Post } from '../api/types'; import { PRIMARY_COLOR } from '../constant'; -// TODO: 关键字高亮 const PostCard = ({ post }: { post: Post }) => { + const location = useLocation(); + const params = new URLSearchParams(location.search); + const fullTextFlag = params.get('f') === 'true'; return ( } className="w-full" extra={查看原文} > @@ -31,14 +34,23 @@ const PostCard = ({ post }: { post: Post }) => { 约 {post.content_length} 字 -
{post.content}
+
') + : post.content, + }} + >
{post.tags && (
{post.tags .slice(1) .split(' #') .map((tag, index) => ( - #{tag} + + {
} + ))}
)} diff --git a/tailwind.config.cjs b/tailwind.config.cjs index ca317f6..858af11 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -1,6 +1,9 @@ /** @type {import('tailwindcss').Config} */ module.exports = { content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'], + safelist: [ + 'text-purple-500' // for uglyHighlight + ], theme: { extend: {}, },