📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Public docs stores and components :tada:
Smaug6739fb61abe0cac2
diff --git a/frontend/app/pages/(public)/doc/[id].vue b/frontend/app/pages/(public)/doc/[id].vuenew file mode 100644index 00000000..73f82879--- /dev/null+++ b/frontend/app/pages/(public)/doc/[id].vue@@ -0,0 +1,90 @@+<template>+ <div style="width: 100%; padding: 1rem 0">+ <!-- ⬇️ Remplace le wrapper inline flex par une classe .reader + style dynamique -->+ <div+ v-if="!error"+ class="reader"+ :style="{+ marginRight: !isTablet() && preferencesStore.get('hideTOC').value && useSidebar().isOpened.value ? '200px' : '0px',+ transition: 'margin 0.3s',+ }"+ >+ <div class="doc-container">+ <DocumentCardHeader :doc="article" :public="true" style="margin: 20px 0" />+ <!-- eslint-disable-next-line vue/no-v-html -->+ <article v-if="article" ref="element" :class="`${article.theme}-theme`" style="max-width: 100%" v-html="article.content_html" />+ <DocumentSkeleton v-else />+ </div>++ <!-- ⬇️ retire le style inline (width/margin-left), on gère en CSS -->+ <div v-if="!isTablet() && !preferencesStore.get('hideTOC').value" class="toc">+ <TableOfContent :doc="article" :element="element" />+ </div>+ </div>++ <Error v-else :error="error" />+ </div>+</template>++<script setup lang="ts">+import TableOfContent from '../../dashboard/docs/_components/table-of-content/TableOfContents.vue';+import DocumentSkeleton from '../../dashboard/docs/_components/DocumentSkeleton.vue';+import DocumentCardHeader from '../../dashboard/docs/_components/DocumentCardHeader.vue';+import type { Document } from '@/stores';++const route = useRoute();+const documentsStore = useDocumentsStore();+const preferencesStore = usePreferences();+const element = ref<HTMLElement>();++const article = ref<Document | 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';+ useHead({ title: article.value?.name || '' });+});+</script>++<style scoped lang="scss">+/* Grille : [1fr] [contenu 800px centré] [1fr pour loger la TOC] */+.reader {+ display: grid;+ grid-template-columns: 1fr minmax(0, 800px) 1fr;+ column-gap: 20px;+ align-items: start;+}++.doc-container {+ grid-column: 2; /* colonne centrale */+ margin: 0; /* plus besoin d'auto */+}++@media screen and (width >= 810px) {+ .doc-container {+ padding: 0 2rem;+ max-width: 800px; /* cohérent avec la colonne centrale */+ }+}++/* La TOC vit dans la colonne de droite, sans décaler le centre */+.toc {+ grid-column: 3; /* colonne droite */+ justify-self: start; /* colle à gauche de la colonne */+ max-width: 320px;+ width: 100%;+ position: sticky; /* optionnel : TOC sticky */+ top: 1rem;+}++/* Cache la TOC quand la colonne droite devient trop étroite */+@media screen and (width <= 1280px) {+ .toc {+ display: none;+ }+}+</style>diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vueindex a6dbccea..60525802 100644--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue@@ -5,11 +5,11 @@<DocumentCardHeaderSkeleton v-if="!doc" /><!-- Real content --><template v-else>- <p class="category">+ <p v-if="!public" class="category"><NuxtLink :to="`/dashboard/categories/${category?.id}`">{{ category?.name }}</NuxtLink><DocumentCardHeaderActionRow :doc="doc" class="no-print" /></p>- <h1 class="title">{{ doc?.name }}</h1>+ <h1 class="title" :class="{ public: public }">{{ doc?.name }}</h1><p class="description">{{ doc?.description }}</p><div v-if="doc.tags" class="document-tags"><tag v-for="tag in doc.tags.split(',')" :key="tag" class="primary">{{ tag.trim() }}</tag>@@ -30,7 +30,7 @@ import type { Document } from '~/stores';const categories_store = useCategoriesStore();const preferences = usePreferences();-const props = defineProps<{ doc?: Document }>();+const props = defineProps<{ doc?: Document; public?: boolean }>();const category = computed(() => categories_store.getById(props.doc?.category || ''));</script>@@ -59,6 +59,9 @@ p {.title {font-family: Inter;}+ .public {+ margin-top: 30px;+ }.title {font-size: 26px;diff --git a/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue b/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vueindex f5e2ced8..c678052b 100644--- a/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue+++ b/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue@@ -12,7 +12,17 @@<textarea id="thumbnail" v-model="document.thumbnail"></textarea><label for="accessibility">Accessibility</label><AppRadio v-model="document.accessibility" :items="DOCUMENT_ACCESSIBILITIES" placeholder="Accessibility" />-+ <!-- Accessibility 3: Public document -->+ <div v-if="document.accessibility === 3" class="public-info">+ <p class="info-text">This document will be publicly accessible via a unique URL.</p>+ <p class="info-text">+ Share this link to allow anyone to view the document without needing an account:+ <br />+ <a :href="link" target="_blank" rel="noopener noreferrer" class="public-link"+ ><Icon name="new_tab" :small="true" fill="var(--font-color-light)" /><span>{{ link }}</span></a+ >+ </p>+ </div><div style="display: flex; align-items: center; gap: 10px"><label for="pinned">Pinned</label><AppToggle id="pinned" v-model="pinnedToggle" />@@ -42,7 +52,7 @@ const store = useDocumentsStore();const props = defineProps<{ doc: Document }>();const document = ref<Document>(props.doc);const pinnedToggle = ref(!!document.value.pinned);-+const link = computed(() => `${window.location.origin}/doc/${document.value.id}`);const documentsTree = computed(() => useSidebarTree().groupedByWorkspace());watch(pinnedToggle, val => (document.value.pinned = val ? 1 : 0));@@ -66,4 +76,31 @@ label {display: flex;align-items: center;}++textarea {+ height: 50px;+ min-height: 50px;+ max-height: 50px;+ resize: none;+ font-size: 14px;+}++.public-info {+ border-radius: 7px;+ padding: 0 5px;+ margin-bottom: 10px;+}+.info-text {+ font-size: 14px;+ color: var(--font-color-light);+ margin: 5px 0;+}+.public-link {+ display: flex;+ align-items: flex-end;+ gap: 2px;+ word-break: break-all;+ color: var(--primary);+ text-decoration: underline;+}</style>diff --git a/frontend/app/pages/dashboard/docs/edit/[id].vue b/frontend/app/pages/dashboard/docs/edit/[id].vueindex 6f5775e3..b33a5192 100644--- a/frontend/app/pages/dashboard/docs/edit/[id].vue+++ b/frontend/app/pages/dashboard/docs/edit/[id].vue@@ -1,5 +1,5 @@<template>- <MarkdownEditor v-if="document" ref="editor" :doc="document" @save="data => save(data)" @autoSave="data => autoSave(data)" @exit="exit" />+ <MarkdownEditor v-if="document" ref="editor" :doc="document" @save="data => save(data)" @auto-save="data => autoSave(data)" @exit="exit" /></template><script lang="ts" setup>import type { Document } from '~/stores';@@ -34,7 +34,7 @@ function save(doc: Document) {}function autoSave(doc: Document) {- store.update(doc)+ store.update(doc);}function exit() {diff --git a/frontend/app/stores/documents.store.ts b/frontend/app/stores/documents.store.tsindex 3e24b911..5acad9b2 100644--- a/frontend/app/stores/documents.store.ts+++ b/frontend/app/stores/documents.store.ts@@ -13,6 +13,7 @@ interface SearchOptions {export const useDocumentsStore = defineStore('documents', {state: () => ({documents: [] as Document[],+ public_documents: [] as Document[],allTags: [] as string[],isFetching: false,}),@@ -117,6 +118,17 @@ export const useDocumentsStore = defineStore('documents', {}} else throw request;},+ async fetchPublic(id: string): Promise<Document | undefined> {+ console.log(`[store/documents] Fetching public document with id: ${id}`);+ const existingDoc = this.public_documents.find(d => d.id === id);+ if (existingDoc) return existingDoc;+ const request = await makeRequest(`documents/public/${id}`, 'GET', {});+ if (request.status === 'success') {+ const fetchedDoc: Document = { ...(request.result as DB_Document), partial: false, type: 'document' };+ this.public_documents.push(fetchedDoc);+ return fetchedDoc;+ } else return undefined;+ },async post(doc: Document): Promise<DB_Document> {const request = await makeRequest('documents', 'POST', doc);if (request.status == 'success') {