diff --git a/components/CommonHead.js b/components/CommonHead.js index cdc12b36..aef00a8e 100644 --- a/components/CommonHead.js +++ b/components/CommonHead.js @@ -1,5 +1,6 @@ import BLOG from '@/blog.config' import Head from 'next/head' +import ThirdPartyScript from '@/components/ThirdPartyScript' const CommonHead = ({ meta }) => { const url = BLOG.path.length ? `${BLOG.link}/${BLOG.path}` : BLOG.link diff --git a/components/Drawer.js b/components/Drawer.js index 7a670907..6f98a6f2 100644 --- a/components/Drawer.js +++ b/components/Drawer.js @@ -3,32 +3,35 @@ import BLOG from '@/blog.config' import SearchInput from '@/components/SearchInput' import MenuButtonGroup from '@/components/MenuButtonGroup' import TocBar from '@/components/TocBar' -import React, { useState } from 'react' +import React, { forwardRef, useImperativeHandle, useState } from 'react' /** * 抽屉面板,可以从侧面拉出 * @returns {JSX.Element} * @constructor */ -const Drawer = ({ post, currentTag }) => { +const Drawer = ({ post, currentTag, cRef }) => { + // 暴露给父组件 通过cRef.current.handleMenuClick 调用 + useImperativeHandle(cRef, () => { + return { + handleMenuClick: () => handleMenuClick() + } + }) const [showDrawer, switchShowDrawer] = useState(false) // 点击按钮更改侧边抽屉状态 const handleMenuClick = () => { switchShowDrawer(!showDrawer) } return
- {/* 触发抽屉按钮 */} -
- -
-
+
{/* LOGO */} -
-
- +
+
+
{
{/* 侧边菜单 */} -
+
- +
{/* 菜单 */} - + {post && (
@@ -56,7 +60,8 @@ const Drawer = ({ post, currentTag }) => {
{/* 背景蒙版 */} -
+
} export default Drawer diff --git a/components/MenuButtonGroup.js b/components/MenuButtonGroup.js index d7ef8d8e..5b9b2d70 100644 --- a/components/MenuButtonGroup.js +++ b/components/MenuButtonGroup.js @@ -23,14 +23,14 @@ const MenuButtonGroup = ({ allowCollapse = false }) => { link.show && (
  • -
    {link.name}
    +
    {link.name}
  • ) diff --git a/components/SideBar.js b/components/SideBar.js index 0b022054..21264289 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -3,7 +3,7 @@ import TocBar from '@/components/TocBar' import MenuButtonGroup from '@/components/MenuButtonGroup' const SideBar = ({ tags, currentTag, post }) => { - return