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.

Start error management

Smaug#67396c4a51c1757f
diff --git a/frontend/components/Error.vue b/frontend/components/Error.vue
new file mode 100644
index 00000000..edec7532
--- /dev/null
+++ b/frontend/components/Error.vue
@@ -0,0 +1,85 @@
+<template>
+ <div class="card-component">
+ <div class="error-content">
+ <h1 class="error-code">{{ props.error?.statusCode }}</h1>
+ <p class="error-message">{{ props.error?.statusMessage || 'Something went wrong' }}</p>
+ <p class="error-description">An unexpected error has occurred. Please check your connection and try refreshing the page or go back to the homepage.</p>
+ <nuxt-link to="/dashboard" class="error-button">Return to Homepage</nuxt-link>
+ </div>
+ <div class="error-illustration">
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500">
+ <circle cx="250" cy="250" r="200" fill="#f3f4f6" />
+ <path d="M250 100 L310 250 L190 250 Z" fill="#1d4ed8" />
+ <circle cx="250" cy="250" r="50" fill="#93c5fd" />
+ </svg>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import type { NuxtError } from '#app';
+
+const props = defineProps({
+ error: Object as () => NuxtError,
+});
+</script>
+
+<style lang="scss" scoped>
+.card-component {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ height: 100%;
+}
+
+.error-content {
+ max-width: 600px;
+ margin-bottom: 20px;
+}
+
+.error-code {
+ font-size: 96px;
+ font-weight: bold;
+ color: var(--font-color);
+ margin: 0;
+}
+
+.error-message {
+ font-size: 24px;
+ font-weight: bold;
+ color: var(--font-color-dark);
+ margin: 10px 0;
+}
+
+.error-description {
+ font-size: 16px;
+ color: var(--font-color-light);
+ margin-bottom: 20px;
+}
+
+.error-button {
+ display: inline-block;
+ padding: 10px 20px;
+ background-color: $primary-color;
+ color: white;
+ text-decoration: none;
+ border-radius: 5px;
+ transition: background-color 0.3s;
+}
+
+.error-button:hover {
+ background-color: $primary-dark;
+}
+
+.error-illustration {
+ margin-top: 20px;
+}
+
+.error-illustration svg {
+ width: 100%;
+ max-width: 300px;
+ height: auto;
+}
+</style>
diff --git a/frontend/components/MediumView.vue b/frontend/components/MediumView.vue
index c46ff448..86c9ff94 100644
--- a/frontend/components/MediumView.vue
+++ b/frontend/components/MediumView.vue
@@ -1,5 +1,5 @@
<template>
- <main class="medium-view" ref="mediumContainer" :style="{ marginLeft, transition }">
+ <main class="medium-view" ref="mediumContainer" :style="{ paddingLeft: marginLeft, transition }">
<slot></slot>
</main>
</template>
@@ -7,8 +7,8 @@
<script setup lang="ts">
const { isOpened, paneWidth, isResizing } = useSidebar();
const mediumContainer = ref<HTMLElement | null>(null);
-const marginLeft = computed(() => (isMobile() || !isOpened.value ? '0' : `${paneWidth.value}px`));
-const transition = computed(() => (isResizing.value ? 'none' : 'margin-left 0.3s'));
+const marginLeft = computed(() => (isMobile() || !isOpened.value ? '16px' : `${paneWidth.value + 16}px`));
+const transition = computed(() => (isResizing.value ? 'none' : 'padding-left 0.3s'));
</script>
<style scoped>
diff --git a/frontend/components/Navbar.vue b/frontend/components/Navbar.vue
index 6486b8da..6720604d 100644
--- a/frontend/components/Navbar.vue
+++ b/frontend/components/Navbar.vue
@@ -18,7 +18,7 @@ header {
display: flex;
align-items: center;
border-bottom: 1px solid var(--border-color);
- margin-bottom: 15px;
+ margin-bottom: 10px;
padding: 10px 0;
}
diff --git a/frontend/pages/dashboard.vue b/frontend/pages/dashboard.vue
index 020e1d61..9012b63c 100644
--- a/frontend/pages/dashboard.vue
+++ b/frontend/pages/dashboard.vue
@@ -1,12 +1,12 @@
<template>
- <div style="display: flex; width: 100%; height: 100%">
+ <div style="width: 100%; height: 100%">
<ClientOnly>
<BackToTop />
</ClientOnly>
<Sidebar />
<MediumView>
<Navbar />
- <NuxtPage />
+ <div style="height: calc(100% - 65px); width: 100%"><NuxtPage /></div>
</MediumView>
</div>
</template>
diff --git a/frontend/pages/dashboard/docs/[id].vue b/frontend/pages/dashboard/docs/[id].vue
index a67da2c2..e2c7fb4d 100644
--- a/frontend/pages/dashboard/docs/[id].vue
+++ b/frontend/pages/dashboard/docs/[id].vue
@@ -10,6 +10,7 @@
<div v-else-if="!isTablet() && preferencesStore.get('hideTOC')" style="margin-right: 200px"></div>
</div>
</div>
+ <Error v-else-if="error" />
</template>
<script setup lang="ts">
@@ -23,15 +24,22 @@ const preferencesStore = usePreferencesStore();
const element = ref<HTMLElement>();
const article = ref<Document | undefined>();
+const error = ref(false);
watchEffect(async () => {
const document_id = route.params.id as string;
const docFromStore = documentsStore.getById(document_id);
+ if (!docFromStore) {
+ return (error.value = true);
+ }
article.value = undefined;
- if (docFromStore?.partial) {
+ if (docFromStore.partial) {
try {
+ error.value = false;
article.value = await documentsStore.fetch({ id: document_id });
- } catch (error) {}
+ } catch (err) {
+ error.value = true;
+ }
} else article.value = docFromStore;
useHead({ title: `Alexandrie ${article.value?.name || ''}` });
});
diff --git a/frontend/styles/code.scss b/frontend/styles/code.scss
index 4989c6ec..3079ab82 100644
--- a/frontend/styles/code.scss
+++ b/frontend/styles/code.scss
@@ -14,6 +14,7 @@ pre {
border-radius: 8px;
margin: 12px 2px;
background: #3b4244;
+ width: 100%;
}
code.hljs {