Graph + Private indicator for navigation + ProseA search improvement

This commit is contained in:
2024-09-04 17:50:03 +02:00
parent 6d3efea784
commit 85c8fbae0f
6 changed files with 32 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ import useDatabase from "~/composables/useDatabase";
import { extname, basename } from 'node:path';
import type { File, FileType } from '~/types/api';
import { CanvasColor, CanvasContent } from "~/types/canvas";
import useMarkdown from "~/composables/useMarkdown";
const typeMapping: Record<string, FileType> = {
".md": "Markdown",
@@ -26,7 +27,7 @@ export default defineTask({
}
}) as any;
const files = await Promise.all(tree.tree.filter((e: any) => !e.path.startsWith(".")).map(async (e: any) => {
const files: File[] = await Promise.all(tree.tree.filter((e: any) => !e.path.startsWith(".")).map(async (e: any) => {
if(e.type === 'tree')
{
const title = basename(e.path);
@@ -56,11 +57,20 @@ export default defineTask({
}
}));
/*let tags = [];
const tagFile = files.find(e => e.path === "tags");
if(tagFile)
{
useMarkdown()(tagFile.content);
tags.push()
}*/
const db = useDatabase();
const oldFiles = db.prepare(`SELECT * FROM explorer_files WHERE project = ?1`).all('1') as File[];
const remove = db.prepare(`DELETE FROM explorer_files WHERE project = ?1 AND path = ?2`);
db.transaction(data => data.forEach(e => { remove.run('1', e.path); /* console.log(`Removing ${e.title}`) */ }))(oldFiles.filter(e => !files.find(f => f.path = e.path)));
db.transaction(data => data.forEach(e => remove.run('1', e.path)))(oldFiles.filter(e => !files.find(f => f.path = e.path)));
remove.finalize();
const insert = db.prepare(`INSERT INTO explorer_files("project", "path", "owner", "title", "order", "type", "content") VALUES (1, $path, 1, $title, $order, $type, $content)`);