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.

Public nodes SEO compatible

Smaug673999f6eeb19cb3
diff --git a/frontend/app/composables/useDevise.ts b/frontend/app/composables/useDevise.ts
index 658e631f..7e243ff6 100644
--- a/frontend/app/composables/useDevise.ts
+++ b/frontend/app/composables/useDevise.ts
@@ -1,15 +1,23 @@
-const width = ref(window.innerWidth);
+/**
+ * Device detection composable
+ * SSR-compatible with client-side hydration
+ */
-const updateWidth = () => {
- width.value = window.innerWidth;
-};
+const width = ref(1024); // Default value for SSR
+const isInitialized = ref(false);
-let isListening = false;
+function updateWidth() {
+ if (import.meta.client) {
+ width.value = window.innerWidth;
+ }
+}
export function useDevice() {
- if (!isListening) {
+ // Initialize on client-side only, once
+ if (import.meta.client && !isInitialized.value) {
+ width.value = window.innerWidth;
window.addEventListener('resize', updateWidth);
- isListening = true;
+ isInitialized.value = true;
}
const isMobile = computed(() => width.value < 768);
diff --git a/frontend/app/pages/(public)/doc/[id]/index.vue b/frontend/app/pages/(public)/doc/[id]/index.vue
index 451a9c20..563333b7 100644
--- a/frontend/app/pages/(public)/doc/[id]/index.vue
+++ b/frontend/app/pages/(public)/doc/[id]/index.vue
@@ -5,7 +5,7 @@
v-if="!error"
class="reader"
:style="{
- marginRight: !devise.isTablet.value && preferencesStore.get('hideTOC').value && sidebar.isOpened.value ? '200px' : '0px',
+ marginRight: !isTablet && preferencesStore.get('hideTOC').value && isOpened ? '200px' : '0px',
transition: 'margin 0.3s',
}"
>
@@ -22,7 +22,7 @@
<DocumentSkeleton v-else />
</div>
- <div v-if="!devise.isTablet.value && !preferencesStore.get('hideTOC').value" class="toc">
+ <div v-if="!isTablet && !preferencesStore.get('hideTOC').value" class="toc">
<TableOfContent :doc="article" :element="element" />
</div>
</div>
@@ -37,45 +37,78 @@ import DocumentSkeleton from '~/pages/dashboard/docs/_components/DocumentSkeleto
import DocumentCardHeader from '~/pages/dashboard/docs/_components/DocumentCardHeader.vue';
import type { Node } from '~/stores';
+definePageMeta({
+ ssr: true,
+});
+
const documentsStore = useNodesStore();
const preferencesStore = usePreferences();
const route = useRoute();
-const sidebar = useSidebar();
-const devise = useDevice();
-
-const element = ref<HTMLElement>();
-
-const article = ref<Node | undefined>();
-const error: Ref<false | string> = ref(false);
-
-watchEffect(async () => {
- article.value = undefined;
- const document_id = route.params.id as string;
- const doc = await documentsStore.fetchPublic(document_id);
- if (doc) article.value = doc;
- else error.value = 'Document not found';
- const title = article.value?.name || 'Unknown Document';
- const description = article.value?.description;
- useHead({
- title: title,
- meta: [
+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;
+
+ article.value = undefined;
+ error.value = undefined;
+
+ const doc = await documentsStore.fetchPublic(documentId);
+
+ if (!doc) {
+ error.value = 'Document not found';
+ return;
+ }
+
+ article.value = doc;
+
+ /**
+ * 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 canonicalUrl = `${baseUrl}/doc/${documentId}`;
+
+ const ogImage = doc.thumbnail ? `${baseUrl}${doc.thumbnail}` : `${baseUrl}/og/default-article.png`;
+
+ useSeoMeta({
// Basic
- { name: 'description', content: description },
-
- // OpenGraph
- { property: 'og:title', content: title },
- { property: 'og:description', content: description },
- { property: 'og:type', content: 'article' },
- { property: 'og:url', content: `${window.location.origin}/doc/${document_id}` },
-
- // Twitter card
- { name: 'twitter:card', content: 'summary_large_image' },
- { name: 'twitter:title', content: title },
- { name: 'twitter:description', content: description },
- ],
- });
-});
+ title,
+ description,
+ keywords: doc.tags,
+
+ // Open Graph
+ ogTitle: title,
+ ogDescription: description,
+ ogType: 'article',
+ ogUrl: canonicalUrl,
+ ogImage,
+
+ // Article metadata
+ articlePublishedTime: new Date(doc.created_timestamp).toISOString(),
+ articleModifiedTime: new Date(doc.updated_timestamp).toISOString(),
+
+ // Twitter
+ twitterCard: 'summary_large_image',
+ twitterTitle: title,
+ twitterDescription: description,
+ twitterImage: ogImage,
+ });
+ },
+ { immediate: true },
+);
</script>
<style scoped lang="scss">
diff --git a/frontend/app/pages/(public)/index.vue b/frontend/app/pages/(public)/index.vue
index 4d71d111..427da882 100644
--- a/frontend/app/pages/(public)/index.vue
+++ b/frontend/app/pages/(public)/index.vue
@@ -49,6 +49,7 @@ import FeaturesFAQ from './_components/features/FeaturesFAQ.vue';
import AppCTA from './_components/AppCTA.vue';
definePageMeta({
+ ssr: true,
middleware: [
function redirectLandingDisabled() {
const config = useRuntimeConfig();