|
2 | 2 | // import BlogPostItem from "@theme-original/BlogPostItem";
|
3 | 3 | import React from 'react';
|
4 | 4 | import clsx from 'clsx';
|
5 |
| -import { useBlogPost} from '@docusaurus/theme-common/internal'; |
6 | 5 | import BlogPostItemContainer from '@theme/BlogPostItem/Container';
|
7 | 6 | import BlogPostItemHeader from '@theme/BlogPostItem/Header';
|
8 | 7 | import BlogPostItemContent from '@theme/BlogPostItem/Content';
|
9 | 8 | import BlogPostItemFooter from '@theme/BlogPostItem/Footer';
|
10 | 9 | import type {Props} from '@theme/BlogPostItem';
|
11 | 10 |
|
12 |
| -// apply a bottom margin in list view |
13 |
| -function useContainerClassName() { |
14 |
| - const {isBlogPostPage} = useBlogPost(); |
15 |
| - return !isBlogPostPage ? 'margin-bottom--xl' : undefined; |
16 |
| -} |
17 |
| - |
18 |
| -export default function BlogPostItem({ |
19 |
| - children, |
20 |
| - className, |
21 |
| -}: Props): JSX.Element { |
| 11 | +export default function BlogPostItem(props) { |
22 | 12 | const containerClassName = useContainerClassName();
|
| 13 | + const { |
| 14 | + children, |
| 15 | + frontMatter, |
| 16 | + metadata, |
| 17 | + truncated, |
| 18 | + isBlogPostPage = false, |
| 19 | + views, |
| 20 | + } = props; |
| 21 | + |
| 22 | + const { date, permalink, tags, readingTime } = metadata; |
| 23 | + |
| 24 | + // activityId, oid 为 B 站评论相关 |
| 25 | + const { |
| 26 | + slug: postId, |
| 27 | + author, |
| 28 | + title, |
| 29 | + image, |
| 30 | + activityId, |
| 31 | + oid, |
| 32 | + bvid, |
| 33 | + } = frontMatter; |
| 34 | + |
| 35 | + const authorURL = frontMatter.author_url || frontMatter.authorURL; |
| 36 | + const authorTitle = frontMatter.author_title || frontMatter.authorTitle; |
| 37 | + const authorImageURL = |
| 38 | + frontMatter.author_image_url || frontMatter.authorImageURL; |
| 39 | + const imageUrl = useBaseUrl(image, { absolute: true }); |
| 40 | + |
| 41 | + // 是否为黑暗主题: |
| 42 | + const theme = useContext(ThemeContext); |
| 43 | + const { isDarkTheme } = theme; |
23 | 44 | return (
|
24 | 45 | <BlogPostItemContainer className={clsx('margin-bottom--xl', className)}>
|
25 | 46 | <script src="https://giscus.app/client.js"
|
|
0 commit comments