Skip to content

Commit

Permalink
history call without withBase() lead to wrong index
Browse files Browse the repository at this point in the history
  • Loading branch information
laplacetw committed Oct 17, 2023
1 parent fefc8d9 commit 04f32da
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .vitepress/theme/components/Pagination.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang='ts'>
import { onMounted } from 'vue'
import { withBase } from 'vitepress'
import { data as posts } from '../posts.data'
import themeConfig from '../config'
import blogStore from '../store'
Expand All @@ -16,10 +18,12 @@ const totalPages = postsLength % postsPerPage === 0
const totalBarLen = Math.ceil(totalPages / pageBarLen)
// 1st page
history.pushState({ page: blogStore.currentPage }, 'goPage()', '/')
window.addEventListener('popstate', e => {
if (e?.state?.page) blogStore.currentPage = e.state.page
});
onMounted(() => {
history.pushState({ page: blogStore.currentPage }, 'goPage()', withBase('/'))
window.addEventListener('popstate', e => {
if (e?.state?.page) blogStore.currentPage = e.state.page
})
})
function genPages() {
let start: number, end: number
Expand All @@ -44,7 +48,7 @@ function genPages() {
function goPage(page: number) {
blogStore.currentPage = page + 1
history.pushState({ page: page + 1 }, 'goPage()', '/')
history.pushState({ page: page + 1 }, 'goPage()', withBase('/'))
}
function showPages(action: string) {
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# 2023-10-17

### Bug Fixes

- history call without withBase() lead to wrong index

# 2023-10-15

### Bug Fixes

- wrong link of post tags due to siteConfig.base

# 2023-10-14

### Bug Fixes

- url error with siteConfig.base

# 2023-10-13

### Features

- add workflow for deploy to GitHub pages

# 2023-10-04

### Features
Expand Down

0 comments on commit 04f32da

Please sign in to comment.