Automatic populatrion of tags
This commit is contained in:
parent
f728b54b02
commit
2328812858
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import PostCard from '$lib/card-collections/cards/PostCard.svelte';
|
||||||
import Header from '$lib/header.svelte';
|
import Header from '$lib/header.svelte';
|
||||||
import PostsSummary from '$lib/posts/PostsSummary.svelte';
|
|
||||||
import type { ArticleSummary } from '$lib/posts/types.js';
|
import type { ArticleSummary } from '$lib/posts/types.js';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
@ -11,6 +11,6 @@
|
|||||||
|
|
||||||
<Header {title} />
|
<Header {title} />
|
||||||
|
|
||||||
{#each posts as article}
|
{#each posts as post}
|
||||||
<PostsSummary {article} />
|
<PostCard {post} />
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -7,25 +7,6 @@ import { mongoConnect } from '$lib/database/mongo.server';
|
|||||||
export async function GET({ url }) {
|
export async function GET({ url }) {
|
||||||
const db = await mongoConnect();
|
const db = await mongoConnect();
|
||||||
const col = db.db('fredboniface').collection('posts');
|
const col = db.db('fredboniface').collection('posts');
|
||||||
// Fetch all possible array values for 'tags' and creata a local `tags` array to return
|
const res = await col.distinct('tags');
|
||||||
// For now, a static array is used.
|
return json(res);
|
||||||
return json(tags);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const tags: string[] = [
|
|
||||||
'svelte',
|
|
||||||
'sveltekit',
|
|
||||||
'python',
|
|
||||||
'bash',
|
|
||||||
'misc',
|
|
||||||
'javascript',
|
|
||||||
'typescript',
|
|
||||||
'go',
|
|
||||||
'node',
|
|
||||||
'express',
|
|
||||||
'mongodb',
|
|
||||||
'redis',
|
|
||||||
'html',
|
|
||||||
'css',
|
|
||||||
'git'
|
|
||||||
];
|
|
Loading…
Reference in New Issue
Block a user