mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
Add filter for draft posts
This commit is contained in:
@@ -2,7 +2,9 @@ import type { MarkdownInstance } from "astro";
|
|||||||
import type { Frontmatter } from "../types";
|
import type { Frontmatter } from "../types";
|
||||||
|
|
||||||
const getSortedPosts = (posts: MarkdownInstance<Frontmatter>[]) =>
|
const getSortedPosts = (posts: MarkdownInstance<Frontmatter>[]) =>
|
||||||
posts.sort(
|
posts
|
||||||
|
.filter(({ frontmatter }) => !frontmatter.draft)
|
||||||
|
.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
Math.floor(new Date(b.frontmatter.datetime).getTime() / 1000) -
|
Math.floor(new Date(b.frontmatter.datetime).getTime() / 1000) -
|
||||||
Math.floor(new Date(a.frontmatter.datetime).getTime() / 1000)
|
Math.floor(new Date(a.frontmatter.datetime).getTime() / 1000)
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import type { Frontmatter } from "../types";
|
|||||||
|
|
||||||
const getUniqueTags = (posts: MarkdownInstance<Frontmatter>[]) => {
|
const getUniqueTags = (posts: MarkdownInstance<Frontmatter>[]) => {
|
||||||
let tags: string[] = [];
|
let tags: string[] = [];
|
||||||
posts.forEach((post) => {
|
const filteredPosts = posts.filter(({ frontmatter }) => !frontmatter.draft);
|
||||||
|
filteredPosts.forEach((post) => {
|
||||||
tags = [...tags, ...post.frontmatter.tags]
|
tags = [...tags, ...post.frontmatter.tags]
|
||||||
.map((tag) => slugify(tag))
|
.map((tag) => slugify(tag))
|
||||||
.filter(
|
.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user