Skip to content

Commit 551bc89

Browse files
authored
update
1 parent 269a6c6 commit 551bc89

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

src/theme/BlogPostItem.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,45 @@
22
// import BlogPostItem from "@theme-original/BlogPostItem";
33
import React from 'react';
44
import clsx from 'clsx';
5-
import { useBlogPost} from '@docusaurus/theme-common/internal';
65
import BlogPostItemContainer from '@theme/BlogPostItem/Container';
76
import BlogPostItemHeader from '@theme/BlogPostItem/Header';
87
import BlogPostItemContent from '@theme/BlogPostItem/Content';
98
import BlogPostItemFooter from '@theme/BlogPostItem/Footer';
109
import type {Props} from '@theme/BlogPostItem';
1110

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) {
2212
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;
2344
return (
2445
<BlogPostItemContainer className={clsx('margin-bottom--xl', className)}>
2546
<script src="https://giscus.app/client.js"

0 commit comments

Comments
 (0)