Переглянути джерело

Merge branch '161-more-sidebar' of craft-in-america/vue-wp into dev

tags/1.0.0
maeda 4 роки тому
джерело
коміт
5ef68717fa

+ 2
- 0
vue-theme/src/components/sidebars/sidebar.vue Переглянути файл

@@ -8,8 +8,10 @@ aside.sidebar
8 8
                 li(v-for="option in sortOptions")
9 9
                     router-link(:to="`/${type}/sorted/${sortTypes[option]}`")
10 10
                         p {{ option }}
11
+                li
11 12
                     router-link(:to="`/${type}`")
12 13
                         p by all
14
+                li
13 15
                     router-link(v-if="shouldShowDateSort.includes(type) && layout !== 'single'" :to="`/${type}/sorted/by-current-and-upcoming`")
14 16
                         p by current and upcoming
15 17
         

+ 12
- 13
vue-theme/src/router/index.js Переглянути файл

@@ -6,14 +6,21 @@ import { convertTitleCase } from '@/utils/helpers'
6 6
 const router = createRouter({
7 7
     history: createWebHistory(),
8 8
     routes,
9
+    scrollBehavior(to, from, savedPosition) {
10
+        let pos = { x: 0, y: 0 }
11
+        if (savedPosition) {
12
+            pos = savedPosition
13
+        }
14
+        if (to.hash) {
15
+            pos = { el: to.hash }
16
+        }
17
+        return pos
18
+    }
9 19
 })
10 20
 
11 21
 router.beforeEach((to, from, next) => {
12 22
     document.title = 'Craft in America'
13 23
 
14
-    // Scroll to top
15
-    window.scrollTo(0, 0)
16
-
17 24
     // Append list type
18 25
     if (to.path.split('/').length > 1 && to.path.split('/')[1]) {
19 26
         const path = convertTitleCase(to.path.split('/')[1])
@@ -24,17 +31,9 @@ router.beforeEach((to, from, next) => {
24 31
         document.title = `${document.title} - ${to.path.split('/')[2]}`
25 32
     }
26 33
 
27
-    // Jump link intercept
28
-    if (to.hash) {
29
-        console.log('jump to:', to.hash)
30
-        const el = document.querySelector(to.hash)
31
-        const barHeight = 50
32
-        window.scrollTo(0, el.offsetTop - barHeight)
33
-    }
34 34
     // Regular links
35
-    else {
36
-        next()
37
-    }
35
+    next()
36
+
38 37
 })
39 38
 
40 39
 export default router

Завантаження…
Відмінити
Зберегти