Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Fix errors

Smaug6739a4d8ecefd4ab
diff --git a/frontend/app/pages/(public)/doc/[id]/index.vue b/frontend/app/pages/(public)/doc/[id]/index.vue
index 563333b7..6c267012 100644
--- a/frontend/app/pages/(public)/doc/[id]/index.vue
+++ b/frontend/app/pages/(public)/doc/[id]/index.vue
@@ -27,10 +27,9 @@
</div>
</div>
- <Error v-else :error="error" />
+ <Error v-else :error="error?.message" />
</div>
</template>
-
<script setup lang="ts">
import TableOfContent from '~/pages/dashboard/docs/_components/table-of-content/TableOfContents.vue';
import DocumentSkeleton from '~/pages/dashboard/docs/_components/DocumentSkeleton.vue';
@@ -49,66 +48,50 @@ const runtimeConfig = useRuntimeConfig();
const { isOpened } = useSidebar();
const { isTablet } = useDevice();
-const element = ref<HTMLElement | undefined>();
-
-const article = ref<Node | undefined>(undefined);
-const error = ref<string | undefined>(undefined);
-
-watch(
- () => route.params.id,
- async documentId => {
- if (!documentId || typeof documentId !== 'string') return;
+const element = ref<HTMLElement>();
- article.value = undefined;
- error.value = undefined;
-
- const doc = await documentsStore.fetchPublic(documentId);
+/**
+ * SSR-aware fetch
+ */
+const { data: article, error } = await useAsyncData(`public-doc-${route.params.id}`, async (): Promise<Node | undefined> => {
+ const documentId = route.params.id;
+ if (!documentId || typeof documentId !== 'string') return undefined;
+ return (await documentsStore.fetchPublic(documentId)) ?? undefined;
+});
- if (!doc) {
- error.value = 'Document not found';
- return;
- }
+/**
+ * SEO (SSR-safe)
+ */
+const title = computed(() => article.value?.name || 'Unknown document');
- article.value = doc;
+const description = computed(() => article.value?.description || 'Public document published on Alexandrie, a modern Markdown-based note-taking platform.');
- /**
- * SEO
- */
- const title = doc.name;
- const description = doc.description || 'Public document published on Alexandrie, a modern Markdown-based note-taking platform.';
+const baseUrl = runtimeConfig.public.baseUrl || 'https://alexandrie-hub.fr';
- const baseUrl = runtimeConfig.public.baseUrl || 'https://alexandrie-hub.fr';
+const canonicalUrl = computed(() => `${baseUrl}/doc/${route.params.id}`);
- const canonicalUrl = `${baseUrl}/doc/${documentId}`;
+const ogImage = computed(() => (article.value?.thumbnail ? `${baseUrl}${article.value.thumbnail}` : `${baseUrl}/og/default-article.png`));
- const ogImage = doc.thumbnail ? `${baseUrl}${doc.thumbnail}` : `${baseUrl}/og/default-article.png`;
+useSeoMeta({
+ title,
+ description,
+ keywords: () => article.value?.tags,
- useSeoMeta({
- // Basic
- title,
- description,
- keywords: doc.tags,
+ ogTitle: title,
+ ogDescription: description,
+ ogType: 'article',
+ ogUrl: canonicalUrl,
+ ogImage,
- // Open Graph
- ogTitle: title,
- ogDescription: description,
- ogType: 'article',
- ogUrl: canonicalUrl,
- ogImage,
+ articlePublishedTime: () => (article.value ? new Date(article.value.created_timestamp).toISOString() : undefined),
- // Article metadata
- articlePublishedTime: new Date(doc.created_timestamp).toISOString(),
- articleModifiedTime: new Date(doc.updated_timestamp).toISOString(),
+ articleModifiedTime: () => (article.value ? new Date(article.value.updated_timestamp).toISOString() : undefined),
- // Twitter
- twitterCard: 'summary_large_image',
- twitterTitle: title,
- twitterDescription: description,
- twitterImage: ogImage,
- });
- },
- { immediate: true },
-);
+ twitterCard: 'summary_large_image',
+ twitterTitle: title,
+ twitterDescription: description,
+ twitterImage: ogImage,
+});
</script>
<style scoped lang="scss">