Skip to content

Commit 2d3680a

Browse files
committed
Merge branch 'v2-more-button' into dev
2 parents 8419d21 + 8c43b53 commit 2d3680a

2 files changed

Lines changed: 39 additions & 4 deletions

File tree

‎apps/codingcatdev/src/routes/(content-list)/ContentCards.svelte‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@
7676
</section>
7777
{#if next}
7878
<div class="flex justify-center m-8">
79-
<button class="text-2xl btn btn-lg btn-primary" on:click={() => more()}> More </button>
79+
<button class="text-2xl bcu-button variant-filled-primary" on:click={() => more()}>
80+
Show More
81+
</button>
8082
</div>
8183
{/if}
8284
</div>
Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
1-
import { listContent } from '$lib/server/content';
1+
import { listContent, parseModules } from '$lib/server/content';
2+
import { ContentType } from '$lib/types';
23
import type { RequestHandler } from '@sveltejs/kit';
34

45
export const POST: RequestHandler = async ({ request }) => {
56
const { contentType, after } = await request.json();
6-
const content = await listContent({ contentType, after });
7-
return new Response(String(JSON.stringify(content)));
7+
let modules;
8+
switch (contentType) {
9+
case ContentType.course:
10+
modules = import.meta.glob(['../../../content/course/*.md']);
11+
break;
12+
case ContentType.framework:
13+
modules = import.meta.glob(['../../../content/framework/*.md']);
14+
break;
15+
case ContentType.language:
16+
modules = import.meta.glob(['../../../content/language/*.md']);
17+
break;
18+
case ContentType.podcast:
19+
modules = import.meta.glob(['../../../content/podcast/*.md']);
20+
break;
21+
case ContentType.post:
22+
modules = import.meta.glob(['../../../content/post/*.md']);
23+
break;
24+
case ContentType.tutorial:
25+
modules = import.meta.glob(['../../../content/tutorial/*.md']);
26+
break;
27+
}
28+
29+
if (!modules) {
30+
return new Response(String(JSON.stringify({
31+
contentType,
32+
contentItems: []
33+
})));
34+
}
35+
36+
const contentItems = await parseModules(modules);
37+
return new Response(String(JSON.stringify({
38+
contentType,
39+
...(await listContent({ contentItems, after }))
40+
})));
841
};

0 commit comments

Comments
 (0)