Fix tags, some parts of the markdown hydration, change how icon works

This commit is contained in:
2024-09-07 22:56:03 +02:00
parent d7a8087c6c
commit 0d1332dcd4
30 changed files with 88 additions and 83 deletions

View File

@@ -2,34 +2,42 @@ import useDatabase from '~/composables/useDatabase';
import type { Tag } from '~/types/api';
export default defineCachedEventHandler(async (e) => {
const project = getRouterParam(e, "projectId");
const tag = getRouterParam(e, "tag");
const query = getQuery(e);
if(!project)
try
{
const project = getRouterParam(e, "projectId");
const tag = getRouterParam(e, "tag");
const query = getQuery(e);
if(!project)
{
setResponseStatus(e, 404);
return;
}
if(!tag)
{
setResponseStatus(e, 404);
return;
}
const where = ["project = $project", "tag = $tag"];
const criteria: Record<string, any> = { $project: project, $tag: tag };
const db = useDatabase();
const content = db.query(`SELECT * FROM explorer_tags WHERE ${where.join(" and ")}`).get(criteria) as Tag;
if(content !== undefined)
{
return content;
}
setResponseStatus(e, 404);
return;
}
if(!tag)
catch(err)
{
setResponseStatus(e, 404);
return;
console.error(err);
setResponseStatus(e, 500);
}
const where = ["project = $project", "tag = $tag"];
const criteria: Record<string, any> = { $project: project, $tag: tag };
const db = useDatabase();
const content = db.query(`SELECT * FROM explorer_tags WHERE ${where.join(" and ")}`).get(criteria) as Tag;
if(content !== undefined)
{
return content;
}
setResponseStatus(e, 404);
}, {
maxAge: 60*60*24,
getKey: (e) => `tag-${getRouterParam(e, "projectId")}-${getRouterParam(e, "tag")}`