Skip to content

Commit 06a9da1

Browse files
committed
视频页tage显示在url中
1 parent 7e2cbf9 commit 06a9da1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/pages/projects/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ function Projects() {
172172
window.$(".stack").lettering();
173173
}, [])
174174

175+
useEffect(() => {
176+
if (!window.location.hash) return
177+
let mayBeTag = decodeURI(window.location.hash.slice(1,window.location.hash.length)).replace('tag_',"")
178+
if (tags.includes(mayBeTag)){
179+
setCurrentTag(mayBeTag)
180+
}
181+
},[])
182+
175183
return (
176184
<Layout title="Projects">
177185
{/*
@@ -188,7 +196,10 @@ function Projects() {
188196
<button
189197
key={tag}
190198
className={clsx(styles.tag, currentTag === tag && styles.tagActive)}
191-
onClick={() => setCurrentTag(tag)}
199+
onClick={() => {
200+
window.location.hash = 'tag_' + tag
201+
setCurrentTag(tag)
202+
}}
192203
>
193204
{ tag }
194205
</button>)

0 commit comments

Comments
 (0)