mirror of
https://github.com/KazooTTT/kazoottt-blog-v2.git
synced 2025-06-17 07:51:21 +08:00
feat: update date sorting function in notes pages
This commit is contained in:
@ -3,7 +3,7 @@ import { type CollectionEntry, getCollection } from "astro:content";
|
|||||||
import Pagination from "@/components/Paginator.astro";
|
import Pagination from "@/components/Paginator.astro";
|
||||||
import Note from "@/components/note/Note.astro";
|
import Note from "@/components/note/Note.astro";
|
||||||
import PageLayout from "@/layouts/Base.astro";
|
import PageLayout from "@/layouts/Base.astro";
|
||||||
import { collectionModifiedDateSort } from "@/utils/date";
|
import { collectionDateSort } from "@/utils/date";
|
||||||
import type { GetStaticPaths, Page } from "astro";
|
import type { GetStaticPaths, Page } from "astro";
|
||||||
import { Icon } from "astro-icon/components";
|
import { Icon } from "astro-icon/components";
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ export const getStaticPaths = (async ({ paginate }) => {
|
|||||||
const MAX_NOTES_PER_PAGE = 10;
|
const MAX_NOTES_PER_PAGE = 10;
|
||||||
const allNotes = await getCollection("note");
|
const allNotes = await getCollection("note");
|
||||||
const notesCount = allNotes.length;
|
const notesCount = allNotes.length;
|
||||||
return paginate(allNotes.sort(collectionModifiedDateSort), {
|
return paginate(allNotes.sort(collectionDateSort), {
|
||||||
pageSize: MAX_NOTES_PER_PAGE,
|
pageSize: MAX_NOTES_PER_PAGE,
|
||||||
props: { notesCount },
|
props: { notesCount },
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@ import { type CollectionEntry, getCollection } from "astro:content";
|
|||||||
import Pagination from "@/components/Paginator.astro";
|
import Pagination from "@/components/Paginator.astro";
|
||||||
import Note from "@/components/note/Note.astro";
|
import Note from "@/components/note/Note.astro";
|
||||||
import PageLayout from "@/layouts/Base.astro";
|
import PageLayout from "@/layouts/Base.astro";
|
||||||
import { collectionModifiedDateSort } from "@/utils/date";
|
import { collectionDateSort } from "@/utils/date";
|
||||||
import type { GetStaticPaths, Page } from "astro";
|
import type { GetStaticPaths, Page } from "astro";
|
||||||
import { Icon } from "astro-icon/components";
|
import { Icon } from "astro-icon/components";
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ export const getStaticPaths = (async ({ paginate }) => {
|
|||||||
const MAX_NOTES_PER_PAGE = 10;
|
const MAX_NOTES_PER_PAGE = 10;
|
||||||
const allNotes = await getCollection("note");
|
const allNotes = await getCollection("note");
|
||||||
const notesCount = allNotes.length;
|
const notesCount = allNotes.length;
|
||||||
return paginate(allNotes.sort(collectionModifiedDateSort), {
|
return paginate(allNotes.sort(collectionDateSort), {
|
||||||
pageSize: MAX_NOTES_PER_PAGE,
|
pageSize: MAX_NOTES_PER_PAGE,
|
||||||
props: { notesCount },
|
props: { notesCount },
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user