File tree 3 files changed +11
-11
lines changed
3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,16 @@ import mdx from "@astrojs/mdx";
2
2
import react from "@astrojs/react" ;
3
3
import sitemap from "@astrojs/sitemap" ;
4
4
import tailwind from "@astrojs/tailwind" ;
5
+ import vercel from "@astrojs/vercel/static" ;
5
6
import { defineConfig } from "astro/config" ;
6
- import vercel from '@astrojs/vercel/static' ;
7
7
8
8
// https://astro.build/config
9
9
export default defineConfig ( {
10
10
site : "https://appclubosu.vercel.app" ,
11
11
integrations : [
12
12
mdx ( {
13
- syntaxHighlight : ' shiki' ,
14
- shikiConfig : { theme : ' github-dark-dimmed' } ,
13
+ syntaxHighlight : " shiki" ,
14
+ shikiConfig : { theme : " github-dark-dimmed" } ,
15
15
gfm : true ,
16
16
} ) ,
17
17
sitemap ( ) ,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const blog = defineCollection({
5
5
schema : z . object ( {
6
6
title : z . string ( ) ,
7
7
description : z . string ( ) ,
8
+ draft : z . optional ( z . boolean ( ) ) ,
8
9
coverImage : z . string ( ) ,
9
10
category : z . string ( ) ,
10
11
// Transform string to Date object
@@ -39,5 +40,4 @@ const guides = defineCollection({
39
40
} ) ,
40
41
} ) ;
41
42
42
-
43
- export const collections = { blog , docs, guides } ;
43
+ export const collections = { blog, docs, guides } ;
Original file line number Diff line number Diff line change @@ -3,9 +3,10 @@ import { getCollection } from "astro:content";
3
3
export async function getCategories ( ) {
4
4
const posts = await getCollection ( "blog" ) ;
5
5
6
- const categories = [
7
- ...new Set ( [ ] . concat . apply ( posts . map ( ( post ) => post . data . category ) ) ) ,
8
- ] ;
6
+ const categories = posts
7
+ . filter ( ( post ) => ! post . data . draft )
8
+ . map ( ( post ) => post . data . category )
9
+ . filter ( ( category , index , self ) => self . indexOf ( category ) === index ) ;
9
10
10
11
return categories ;
11
12
}
@@ -14,16 +15,15 @@ export async function getPosts() {
14
15
const posts = ( await getCollection ( "blog" ) ) . sort (
15
16
( a , b ) => b . data . pubDate . valueOf ( ) - a . data . pubDate . valueOf ( )
16
17
) ;
17
-
18
- return posts ;
18
+ return posts . filter ( ( post ) => ! post . data . draft ) ;
19
19
}
20
20
21
21
export async function getPostsByCategory ( category : string ) {
22
22
const posts = ( await getCollection ( "blog" ) )
23
23
. filter ( ( post ) => post . data . category === category )
24
24
. sort ( ( a , b ) => b . data . pubDate . valueOf ( ) - a . data . pubDate . valueOf ( ) ) ;
25
25
26
- return posts ;
26
+ return posts . filter ( ( post ) => ! post . data . draft ) ;
27
27
}
28
28
29
29
export async function getGuides ( ) {
You can’t perform that action at this time.
0 commit comments