Skip to content

Commit

Permalink
fix: update to use archives endpoint to avoid feature post affect
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Aug 15, 2023
1 parent 3c8d224 commit c207a16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ export async function fetchPostsList(
return request.get<PostList>(`/posts/${currentPage}.json`)
}

// GET /api/posts/:pageNum.json (default 1.json)
export async function fetchArchivesList(
currentPage: number
): Promise<AxiosResponse<any>> {
return request.get<PostList>(`/archives/${currentPage}.json`)
}

// GET /api/tags/:TagName.json
export async function fetchPostsListByTag(
tagName: string
Expand Down
5 changes: 3 additions & 2 deletions src/stores/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
fetchPostsList,
fetchPostBySlug,
fetchPostsListByCategory,
fetchPostsListByTag
fetchPostsListByTag,
fetchArchivesList
} from '@/api'

export const usePostStore = defineStore({
Expand Down Expand Up @@ -52,7 +53,7 @@ export const usePostStore = defineStore({
},
async fetchArchives(page?: number): Promise<Archives> {
if (!page) page = 1
const { data } = await fetchPostsList(page)
const { data } = await fetchArchivesList(page)
return new Promise(resolve =>
setTimeout(() => {
resolve(new Archives(data))
Expand Down

0 comments on commit c207a16

Please sign in to comment.