You've already forked obsidian-visualiser
Fix tags, some parts of the markdown hydration, change how icon works
This commit is contained in:
@@ -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")}`
|
||||
|
||||
Reference in New Issue
Block a user