Browse Source

fix blog index redirect

mrkvon 1 year ago
parent
commit
ecef7b70fe
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      src/pages/blog/index.js

+ 4
- 1
src/pages/blog/index.js View File

@@ -1,11 +1,14 @@
1 1
 import { graphql } from "gatsby"
2
+import { useEffect } from "react"
2 3
 
3 4
 export default function BlogIndexRedirect({
4 5
   data: {
5 6
     postsYaml: { url },
6 7
   },
7 8
 }) {
8
-  window.location = `/blog/${url}`
9
+  useEffect(() => {
10
+    window.location = `/blog/${url}`
11
+  }, [url])
9 12
   return null
10 13
 }
11 14