You've already forked obsidian-visualiser
New useContent composable to store global navigation state. Fixes for Markdown and Canvas
This commit is contained in:
@@ -50,7 +50,7 @@ export default defineEventHandler(async (e) => {
|
||||
content.content = convertFromStorableLinks(content.content);
|
||||
}
|
||||
|
||||
return { content: content.content };
|
||||
return content.content;
|
||||
}
|
||||
|
||||
setResponseStatus(e, 404);
|
||||
|
||||
41
server/api/file/overview.get.ts
Normal file
41
server/api/file/overview.get.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import useDatabase from '~/composables/useDatabase';
|
||||
import { getTableColumns } from 'drizzle-orm';
|
||||
import { explorerContentTable } from '~/db/schema';
|
||||
|
||||
export default defineEventHandler(async (e) => {
|
||||
const { user } = await getUserSession(e);
|
||||
|
||||
const db = useDatabase();
|
||||
const { content: _, ...columns } = getTableColumns(explorerContentTable);
|
||||
const content = db.select(columns).from(explorerContentTable).all();
|
||||
|
||||
content.sort((a, b) => {
|
||||
return a.path.split('/').length - b.path.split('/').length;
|
||||
});
|
||||
|
||||
if(content.length > 0)
|
||||
{
|
||||
for(const idx in content)
|
||||
{
|
||||
const item = content[idx];
|
||||
if(!!item.private && (user?.id ?? -1) !== item.owner)
|
||||
{
|
||||
delete content[idx];
|
||||
continue;
|
||||
}
|
||||
|
||||
const parent = item.path.includes('/') ? item.path.substring(0, item.path.lastIndexOf('/')) : undefined;
|
||||
|
||||
if(parent && !content.find(e => e && e.path === parent))
|
||||
{
|
||||
delete content[idx];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return content.filter(e => !!e);
|
||||
}
|
||||
|
||||
setResponseStatus(e, 404);
|
||||
return;
|
||||
});
|
||||
Reference in New Issue
Block a user