diff --git a/components/NotionPage.js b/components/NotionPage.js index 014a5b33..4b7f2808 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -37,7 +37,7 @@ const Modal = dynamic( () => import('react-notion-x/build/third-party/modal').then((m) => m.Modal), { ssr: false } ) -const NotionPage = ({ post }) => { +const NotionPage = ({ post, className }) => { const zoom = isBrowser() && mediumZoom({ container: '.notion-viewport', background: 'rgba(0, 0, 0, 0.2)', @@ -80,7 +80,7 @@ const NotionPage = ({ post }) => { return <>{post?.summary || ''} } - return
+ return
{ } } +async function getNotice(post) { + if (!post) { + return null + } + + post.blockMap = await getPostBlocks(post.id, 'data-notice') + return post +} + /** * 调用NotionAPI获取Page数据 * @returns {Promise} @@ -236,6 +245,7 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { }) } + const notice = await getNotice(collectionData.filter(post => { return post?.type === 'Notice' && post.status === 'Published' })?.[0]) const categoryOptions = getAllCategories({ allPages, categoryOptions: getCategoryOptions(schema) }) const tagOptions = getAllTags({ allPages, tagOptions: getTagOptions(schema) }) const siteInfo = getBlogInfo({ collection, block }) @@ -243,6 +253,7 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 5 }) return { + notice, siteInfo, allPages, collection, diff --git a/styles/globals.css b/styles/globals.css index d7b7ed75..ff6f6fb0 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -206,3 +206,8 @@ nav { .nobelium .notion-code{ @apply max-w-2xl; } + +.next #announcement-content *{ + font-size:10px !important; + line-height:1.5 !important; +} \ No newline at end of file diff --git a/themes/hexo/components/Announcement.js b/themes/hexo/components/Announcement.js new file mode 100644 index 00000000..27ca0462 --- /dev/null +++ b/themes/hexo/components/Announcement.js @@ -0,0 +1,24 @@ +import dynamic from 'next/dynamic' + +const NotionPage = dynamic(() => import('@/components/NotionPage')) + +const Announcement = ({ post, className }) => { + if (!post) { + return <> + } + return
+
+
公告
+ {post && (
+ +
)} +
+
+} +export default Announcement diff --git a/themes/hexo/components/LatestPostsGroup.js b/themes/hexo/components/LatestPostsGroup.js index a6741fc2..cfb44018 100644 --- a/themes/hexo/components/LatestPostsGroup.js +++ b/themes/hexo/components/LatestPostsGroup.js @@ -57,8 +57,8 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => {
) - ); + ) })} - ; + } export default LatestPostsGroup diff --git a/themes/hexo/components/SideRight.js b/themes/hexo/components/SideRight.js index 8680f144..68ae58cc 100644 --- a/themes/hexo/components/SideRight.js +++ b/themes/hexo/components/SideRight.js @@ -8,6 +8,7 @@ import { AnalyticsCard } from './AnalyticsCard' import CONFIG_HEXO from '../config_hexo' import BLOG from '@/blog.config' import dynamic from 'next/dynamic' +import Announcement from './Announcement' const HexoRecentComments = dynamic(() => import('./HexoRecentComments')) /** @@ -18,9 +19,8 @@ const HexoRecentComments = dynamic(() => import('./HexoRecentComments')) export default function SideRight(props) { const { post, currentCategory, categories, latestPosts, tags, - currentTag, showCategory, showTag, slot + currentTag, showCategory, showTag, slot, notice } = props - return (
@@ -46,6 +46,8 @@ export default function SideRight(props) { } + + {BLOG.COMMENT_WALINE_SERVER_URL && BLOG.COMMENT_WALINE_RECENT && }
diff --git a/themes/next/LayoutBase.js b/themes/next/LayoutBase.js index 81cb5037..647dbcc8 100644 --- a/themes/next/LayoutBase.js +++ b/themes/next/LayoutBase.js @@ -69,7 +69,7 @@ const LayoutBase = (props) => {
-
+
{/* 左侧栏样式 */}
diff --git a/themes/next/components/Announcement.js b/themes/next/components/Announcement.js new file mode 100644 index 00000000..e7b2d9f5 --- /dev/null +++ b/themes/next/components/Announcement.js @@ -0,0 +1,21 @@ +import dynamic from 'next/dynamic' + +const NotionPage = dynamic(() => import('@/components/NotionPage')) + +const Announcement = ({ post, className }) => { + if (!post) { + return <> + } + return <> +
+
+ + 公告 +
+
+ {post && (
+ +
)} + +} +export default Announcement diff --git a/themes/next/components/BlogPostCard.js b/themes/next/components/BlogPostCard.js index 65352c12..a73abbd5 100644 --- a/themes/next/components/BlogPostCard.js +++ b/themes/next/components/BlogPostCard.js @@ -116,7 +116,7 @@ const BlogPostCard = ({ post, showSummary }) => { )}
- ); + ) } export default BlogPostCard diff --git a/themes/next/components/LatestPostsGroup.js b/themes/next/components/LatestPostsGroup.js index 7b0f9012..a12f55b5 100644 --- a/themes/next/components/LatestPostsGroup.js +++ b/themes/next/components/LatestPostsGroup.js @@ -48,8 +48,8 @@ const LatestPostsGroup = ({ latestPosts }) => {
) - ); + ) })} - ; + } export default LatestPostsGroup diff --git a/themes/next/components/SideAreaLeft.js b/themes/next/components/SideAreaLeft.js index 2404b5e0..a2f8b67f 100644 --- a/themes/next/components/SideAreaLeft.js +++ b/themes/next/components/SideAreaLeft.js @@ -41,7 +41,9 @@ const SideAreaLeft = props => { {CONFIG_NEXT.MENU_SEARCH &&
} + +
diff --git a/themes/next/components/SideAreaRight.js b/themes/next/components/SideAreaRight.js index 6d89c625..26372663 100644 --- a/themes/next/components/SideAreaRight.js +++ b/themes/next/components/SideAreaRight.js @@ -8,6 +8,7 @@ import CONFIG_NEXT from '../config_next' import { useRouter } from 'next/router' import BLOG from '@/blog.config' import dynamic from 'next/dynamic' +import Announcement from './Announcement' const NextRecentComments = dynamic(() => import('./NextRecentComments')) /** @@ -21,82 +22,88 @@ const NextRecentComments = dynamic(() => import('./NextRecentComments')) * @constructor */ const SideAreaRight = (props) => { - const { tags, currentTag, slot, categories, currentCategory } = props + const { tags, currentTag, slot, categories, currentCategory, notice } = props const { locale } = useGlobal() const router = useRouter() - return ( ) } export default SideAreaRight diff --git a/themes/nobelium/components/Nav.js b/themes/nobelium/components/Nav.js index 33638b23..f35b60b1 100644 --- a/themes/nobelium/components/Nav.js +++ b/themes/nobelium/components/Nav.js @@ -104,7 +104,6 @@ const NavBar = props => { if (customNav) { links = links.concat(customNav) } - console.log(links) return (
    diff --git a/themes/nobelium/components/Tags.js b/themes/nobelium/components/Tags.js index ae93d85a..bdab3ee5 100644 --- a/themes/nobelium/components/Tags.js +++ b/themes/nobelium/components/Tags.js @@ -2,7 +2,6 @@ import Link from 'next/link' const Tags = props => { const { tagOptions, tag } = props - console.log(props) const currentTag = tag if (!tagOptions) return null return (