Skip to content

Commit

Permalink
增加判断路径来返回宽度
Browse files Browse the repository at this point in the history
增加点击效果
  • Loading branch information
buyfakett committed Feb 24, 2025
1 parent 7b2ffa6 commit 03e7756
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/util/Comment.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import React from 'react';
import Giscus from '@giscus/react';
import { useLocation } from 'react-router';

const Comment = () => {
const location = useLocation(); // 获取当前路径
const currentPath = location.pathname;
let commentWidth;

switch (currentPath) {
case '/pictures':
case '/coffee':
commentWidth = 'w-[80%]';
break;
case '/projects':
commentWidth = 'w-[70%]';
break;
default:
commentWidth = 'w-[60%]';
break;
}

return (
<div className="w-[60%] mx-auto mt-10">
<div className={`${commentWidth} mx-auto mt-10`}>
<Giscus
id="comments"
repo="buyfakett/blog-comments"
Expand Down
2 changes: 1 addition & 1 deletion src/view/AboutMe/OpenSourceProjects.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const OpenSourceProjects = () => {
navigate('/projects');
window.scrollTo(0, 0);
}}
className="flex items-center gap-2 text-white ml-auto mr-10">
className="flex items-center cursor-pointer gap-2 text-white ml-auto mr-10">
<CiLink className="w-5 h-5" />
<span className="text-sm">More Projects</span>
</button>
Expand Down

0 comments on commit 03e7756

Please sign in to comment.