Automatic populatrion of tags

This commit is contained in:
Fred Boniface 2023-08-22 20:50:19 +01:00
parent f728b54b02
commit 2328812858
2 changed files with 6 additions and 25 deletions

View File

@ -1,6 +1,6 @@
<script lang="ts">
import PostCard from '$lib/card-collections/cards/PostCard.svelte';
import Header from '$lib/header.svelte';
import PostsSummary from '$lib/posts/PostsSummary.svelte';
import type { ArticleSummary } from '$lib/posts/types.js';
export let data;
@ -11,6 +11,6 @@
<Header {title} />
{#each posts as article}
<PostsSummary {article} />
{#each posts as post}
<PostCard {post} />
{/each}

View File

@ -7,25 +7,6 @@ import { mongoConnect } from '$lib/database/mongo.server';
export async function GET({ url }) {
const db = await mongoConnect();
const col = db.db('fredboniface').collection('posts');
// Fetch all possible array values for 'tags' and creata a local `tags` array to return
// For now, a static array is used.
return json(tags);
}
const tags: string[] = [
'svelte',
'sveltekit',
'python',
'bash',
'misc',
'javascript',
'typescript',
'go',
'node',
'express',
'mongodb',
'redis',
'html',
'css',
'git'
];
const res = await col.distinct('tags');
return json(res);
}