Skip to content

Commit d2e3fcf

Browse files
committed
add scheduled aka draft
1 parent 06113d6 commit d2e3fcf

8 files changed

Lines changed: 44 additions & 23 deletions

File tree

‎apps/codingcatdev/src/lib/server/content.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ContentType, ContentPublished } from '$lib/types';
2-
import type { Content, Course, Lesson, Podcast } from '$lib/types';
2+
import type { Content, Course, Podcast } from '$lib/types';
33

44
const LIMIT = 20;
55

@@ -115,19 +115,21 @@ for (const path in lessonModules) {
115115
export const listContent = async ({
116116
contentType,
117117
after,
118-
limit
118+
limit,
119+
contentFilter = (c) => c.published === ContentPublished.published
119120
}: {
120121
contentType: ContentType;
121122
after?: number;
122123
limit?: number;
124+
contentFilter?: (c: Content) => boolean;
123125
}) => {
124126
const theLimit = limit || LIMIT;
125127
const theAfter = after || 0;
126128

127129
console.log(`List for type: ${contentType}, limit of ${theLimit}`);
128130

129131
const fullContent = markdownFiles[contentType as keyof typeof markdownFiles]
130-
.filter((c) => c.published === ContentPublished.published)
132+
.filter(contentFilter)
131133
.sort((a, b) => new Date(b.start).valueOf() - new Date(a.start).valueOf());
132134

133135
const content = fullContent.slice(0 + theAfter, theLimit + theAfter);
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<script>
1+
<script lang="ts">
22
import ContentCards from '$lib/components/content/ContentCards.svelte';
33
import { ContentType } from '$lib/types/index';
4-
5-
/** @type {import('./$types').PageData} */
6-
export let data;
4+
import type { PageData } from './$types';
5+
export let data: PageData;
76
</script>
87

98
<ContentCards type={ContentType.post} {data} />
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<script>
1+
<script lang="ts">
22
import ContentCards from '$lib/components/content/ContentCards.svelte';
33
import { ContentType } from '$lib/types/index';
4-
5-
/** @type {import('./$types').PageData} */
6-
export let data;
4+
import type { PageData } from './$types';
5+
export let data: PageData;
76
</script>
87

98
<ContentCards type={ContentType.course} {data} />
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<script>
1+
<script lang="ts">
22
import ContentCards from '$lib/components/content/ContentCards.svelte';
33
import { ContentType } from '$lib/types/index';
4-
5-
/** @type {import('./$types').PageData} */
6-
export let data;
4+
import type { PageData } from './$types';
5+
export let data: PageData;
76
</script>
87

98
<ContentCards type={ContentType.framework} {data} />
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<script>
1+
<script lang="ts">
22
import ContentCards from '$lib/components/content/ContentCards.svelte';
33
import { ContentType } from '$lib/types/index';
4-
5-
/** @type {import('./$types').PageData} */
6-
export let data;
4+
import type { PageData } from './$types';
5+
export let data: PageData;
76
</script>
87

98
<ContentCards type={ContentType.language} {data} />
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<script>
1+
<script lang="ts">
22
import ContentCards from '$lib/components/content/ContentCards.svelte';
33
import { ContentType } from '$lib/types/index';
4-
5-
/** @type {import('./$types').PageData} */
6-
export let data;
4+
import type { PageData } from './$types';
5+
export let data: PageData;
76
</script>
87

98
<ContentCards type={ContentType.podcast} {data} />
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { listContent } from '$lib/server/content';
2+
import { ContentPublished, ContentType } from '$lib/types';
3+
import type { PageServerLoad } from './$types';
4+
5+
const contentType = ContentType.podcast;
6+
7+
export const load = (async () => {
8+
return {
9+
contentType,
10+
...(await listContent({
11+
contentType,
12+
contentFilter: (c) => c.published === ContentPublished.draft
13+
}))
14+
};
15+
}) satisfies PageServerLoad;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
import ContentCards from '$lib/components/content/ContentCards.svelte';
3+
import { ContentType } from '$lib/types/index';
4+
5+
/** @type {import('./$types').PageData} */
6+
export let data;
7+
</script>
8+
9+
<ContentCards type={ContentType.post} {data} />

0 commit comments

Comments
 (0)