diff --git a/components/explorer/NavigationLink.vue b/components/explorer/NavigationLink.vue index 0a5af20..6fe4ed9 100644 --- a/components/explorer/NavigationLink.vue +++ b/components/explorer/NavigationLink.vue @@ -19,22 +19,27 @@ const emit = defineEmits(['navigate']); \ No newline at end of file diff --git a/components/prose/ProseA.vue b/components/prose/ProseA.vue index 4128239..2eeba5c 100644 --- a/components/prose/ProseA.vue +++ b/components/prose/ProseA.vue @@ -34,7 +34,8 @@ const props = defineProps({ const route = useRoute(); const { hash, pathname, protocol } = parseURL(props.href); const project = computed(() => parseInt(Array.isArray(route.params.projectId) ? '0' : route.params.projectId)); -const { data, status } = await useFetch(`/api/project/${project.value}/file`, { + +const { data, status, execute } = await useFetch(`/api/project/${project.value}/file`, { method: 'GET', query: { search: `%${pathname}` @@ -43,5 +44,11 @@ const { data, status } = await useFetch(`/api/project/${project.value}/file`, { key: `file:${project.value}:%${pathname}`, dedupe: 'defer', ignoreResponseError: true, + immediate: false, }); + +if(pathname && !protocol) +{ + execute(); +} \ No newline at end of file diff --git a/components/prose/ProseTag.vue b/components/prose/ProseTag.vue index b2b1ff9..d022531 100644 --- a/components/prose/ProseTag.vue +++ b/components/prose/ProseTag.vue @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/components/standard/Input.vue b/components/standard/Input.vue index aefea72..34ee7e5 100644 --- a/components/standard/Input.vue +++ b/components/standard/Input.vue @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/db.sqlite b/db.sqlite index f3a6135..7f7119b 100644 Binary files a/db.sqlite and b/db.sqlite differ diff --git a/server/tasks/sync.ts b/server/tasks/sync.ts index 357061a..5a998e5 100644 --- a/server/tasks/sync.ts +++ b/server/tasks/sync.ts @@ -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 = { ".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)`);