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.

10.5 KB
Raw Blame
import { defineNuxtConfig } from 'nuxt/config';
import { resolve } from 'path';
import { createSvgIconsPlugin } from './vite/plugins/svg-sprite';
import type { NuxtPage } from 'nuxt/schema';

export default defineNuxtConfig({
  /**
   ************************ Application ************************
   */
  app: {
    head: {
      charset: 'utf-8',
      htmlAttrs: {
        lang: 'en',
      },
      link: [
        {
          href: '/manifest.webmanifest',
          rel: 'manifest',
        },
        {
          href: '/favicon-dark.ico',
          media: '(prefers-color-scheme: dark)',
          rel: 'icon',
          type: 'image/x-icon',
        },
        {
          href: '/favicon.ico',
          media: '(prefers-color-scheme: light), (prefers-color-scheme: no-preference)',
          rel: 'icon',
          type: 'image/x-icon',
        },
        { href: 'https://embed.diagrams.net', rel: 'preconnect' },
      ],
      meta: [
        // SEO (url meta tags are defined in App.vue for dynamic URLs)
        {
          content:
            'Alexandrie is a modern note-taking and knowledge base application built for students & creators. Write, organize and render beautiful notes using extended Markdown in a fast, clean and distraction-free interface. Self-hostable with Docker.',
          name: 'description',
        },
        {
          content:
            'markdown notes, note taking app, knowledge base, developer notes, markdown editor, personal wiki, technical documentation, pwa notes, docker, self-hosted',
          name: 'keywords',
        },
        { content: 'Alexandrie Team', name: 'author' },
        { content: 'index, follow', name: 'robots' },
        { content: 'strict-origin-when-cross-origin', name: 'referrer' },

        // PWA / Mobile
        { content: 'Alexandrie', name: 'application-name' },
        { content: 'Alexandrie', name: 'apple-mobile-web-app-title' },
        { content: 'yes', name: 'apple-mobile-web-app-capable' },
        { content: 'yes', name: 'mobile-web-app-capable' },
        { content: '#3956e7', name: 'theme-color' },

        // Open Graph
        { content: 'website', property: 'og:type' },
        { content: 'Alexandrie', property: 'og:site_name' },
        { content: 'Alexandrie – Modern Markdown Note-Taking & Knowledge Base App', property: 'og:title' },
        {
          content: 'A modern note-taking and knowledge base app for students and creators, built around extended Markdown and self-hostable with Docker.',
          property: 'og:description',
        },
        { content: '/icons/icon-192.png', property: 'og:image' },

        // Twitter Card
        { content: 'Alexandrie – Modern Markdown Note-Taking & Knowledge Base App', name: 'twitter:title' },
        {
          content: 'Write and organize beautiful notes with extended Markdown. Fast, clean and developer-friendly. Self-hostable with Docker.',
          name: 'twitter:description',
        },
        { content: 'summary', name: 'twitter:card' },
        { content: '/icons/icon-192.png', name: 'twitter:image' },
        { content: 'Alexandrie', name: 'twitter:image:alt' },
      ],
      title: 'Alexandrie | Modern Markdown Note-Taking & Knowledge Base App',
      viewport: 'width=device-width, initial-scale=1',

      style: [
        {
          id: 'dynamic-theme-vars',
          innerHTML: `
        :root {
          --primary: var(--accent);
          --primary-dark: var(--accent-dark);
          --primary-bg: var(--accent-bg);
          --primary-border: var(--accent-border);
        }
      `,
        },
      ],
    },
  },

  /**
   ************************ General ************************
   */
  ssr: true,
  compatibilityDate: '2024-07-19',
  devtools: { enabled: process.env.NODE_ENV !== 'production' },
  spaLoadingTemplate: './splash-screen.html',
  routeRules: {
    '/dashboard/**': { ssr: false },
    '/dashboard': { ssr: false },
  },
  /**
   ************************ Imports & modules ************************
   */
  imports: {
    dirs: ['stores/**'],
  },
  modules: ['@pinia/nuxt', '@nuxtjs/color-mode', '@vite-pwa/nuxt', '@nuxt/eslint', '@nuxtjs/i18n'],

  /**
   ************************ Styles ************************
   */
  css: ['~/styles/main.scss', '~/styles/vendors/katex/katex.min.css'],
  colorMode: {
    classSuffix: '-mode',
    fallback: 'light', // fallback value if not system preference found
    preference: 'light', // default value of $colorMode.preference
  },
  /**
   ************************ Internationalization ************************
   */
  i18n: {
    defaultLocale: 'en',
    experimental: {
      preload: false,
      stripMessagesPayload: true,
      typedOptionsAndMessages: 'default',
    },
    detectBrowserLanguage: {
      useCookie: false,
      redirectOn: 'root',
    },
    locales: [
      { code: 'en', file: 'en/index.ts', language: 'en-US' },
      { code: 'fr', file: 'fr/index.ts', language: 'fr-FR' },
      { code: 'de', file: 'de/index.ts', language: 'de-DE' },
      { code: 'uk', file: 'uk/index.ts', language: 'uk-UA' },
      { code: 'ko', file: 'ko/index.ts', language: 'ko-KR' },
      { code: 'it', file: 'it/index.ts', language: 'it-IT' },
      // zh-CN is listed first on purpose: any inexact zh-* tag (zh, zh-Hans, zh-Hant)
      // falls back to the first zh-* entry, and zh-Hans is what Chrome/Android actually send.
      // Exact zh-TW / zh-HK matches are unaffected by the order.
      { code: 'zh-CN', file: 'zh-CN/index.ts', language: 'zh-CN' },
      { code: 'zh-TW', file: 'zh-TW/index.ts', language: 'zh-TW' },
    ],
    strategy: 'prefix_except_default',
    skipSettingLocaleOnNavigate: true,

    baseUrl: import.meta.env.NUXT_PUBLIC_BASE_URL,
    pages: {
      'dashboard/index': false,
      'dashboard/[...all]': false,
    },
  },
  /**
   ************************ Experimental ************************
   */
  experimental: {
    defaults: {
      nuxtLink: {
        // prefetch: false,
      },
    },
    payloadExtraction: true,
    viewTransition: true,
    viteEnvironmentApi: true,
  },
  /**
   ************************ Runetime config ************************
   */
  runtimeConfig: {
    public: {
      // Base URLs
      baseApi: '',
      baseCdn: '',
      cdnEndpoint: '/alexandrie/',
      configDisableLandingPage: '',
      configDisableNativeLogin: false,
      configHideNativeLogin: false,
      // Feature flags
      configDisableSignupPage: '',
      configOidcProviderAutoRedirect: '',
    },
  },

  /**
   ************************ Nitro ************************
   */
  nitro: {
    compressPublicAssets: true,
    minify: true,
    experimental: {
      // envExpansion: true,
    },
  },
  /**
   ************************ PWA ************************
   */
  pwa: {
    base: '/',
    filename: 'sw.ts',
    injectManifest: {
      globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
      maximumFileSizeToCacheInBytes: 30_000_000,
    },
    manifest: {
      background_color: '#334155',
      description: 'App for taking beautiful notes in extended Markdown format.',
      display: 'standalone',
      icons: [
        {
          purpose: 'maskable',
          sizes: '144x144',
          src: '/icons/icon-m-144.png',
          type: 'image/png',
        },
        {
          purpose: 'maskable',
          sizes: '192x192',
          src: '/icons/icon-m-192.png',
          type: 'image/png',
        },
        {
          purpose: 'maskable',
          sizes: '512x512',
          src: '/icons/icon-m-512.png',
          type: 'image/png',
        },
        {
          purpose: 'any',
          sizes: '144x144',
          src: '/icons/icon-144.png',
          type: 'image/png',
        },
        {
          purpose: 'any',
          sizes: '192x192',
          src: '/icons/icon-192.png',
          type: 'image/png',
        },
        {
          purpose: 'any',
          sizes: '512x512',
          src: '/icons/icon-512.png',
          type: 'image/png',
        },
      ],
      name: 'Alexandrie',
      screenshots: [
        {
          form_factor: 'wide',
          label: 'Note rendering',
          sizes: '1920x1080',
          src: '/screenshots/mock/1.png',
          type: 'image/png',
        },
        {
          form_factor: 'wide',
          label: 'Note editor',
          sizes: '1920x1080',
          src: '/screenshots/mock/2.png',
          type: 'image/png',
        },
        {
          form_factor: 'wide',
          label: 'Note list',
          sizes: '1920x1080',
          src: '/screenshots/mock/3.png',
          type: 'image/png',
        },
        {
          form_factor: 'narrow',
          label: 'Demo phone',
          sizes: '1920x1920',
          src: '/screenshots/mock/phone-1.png',
          type: 'image/png',
        },
      ],
      share_target: {
        action: '/dashboard/share-target',
        enctype: 'multipart/form-data',
        method: 'POST',
        params: {
          files: [
            {
              accept: ['image/*', 'application/pdf', 'text/*', 'application/json', '.md', '.txt', '.json', '.csv'],
              name: 'files',
            },
          ],
          text: 'text',
          title: 'title',
          url: 'url',
        },
      },
      short_name: 'Alexandrie',
      start_url: '/dashboard',
      scope: '/',
      theme_color: '#3956e7',
    },
    registerType: 'autoUpdate',
    srcDir: '.',
    strategies: 'injectManifest',
  },
  /**
   ************************ Hooks ************************
   */
  hooks: {
    'pages:extend'(pages: NuxtPage[]) {
      function remove(pages: NuxtPage[]) {
        for (const page of [...pages]) {
          if (page.file?.includes('/components/') || page.file?.includes('/_')) {
            pages.splice(pages.indexOf(page), 1);
          }

          if (page.children) remove(page.children);
        }
      }

      remove(pages);
    },
  },
  /**
   ************************ Vite ************************
   */

  vite: {
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: "@use '~/styles/abstract/static.scss' as *;",
        },
      },
    },
    define: {
      __BASE_URL__: JSON.stringify(import.meta.env.NUXT_PUBLIC_BASE_URL || ''),
      __BASE_CDN__: JSON.stringify(import.meta.env.NUXT_PUBLIC_BASE_CDN || ''),
      __BASE_API__: JSON.stringify(import.meta.env.NUXT_PUBLIC_BASE_API || ''),
    },
    plugins: [
      createSvgIconsPlugin({
        iconDirs: [resolve(process.cwd(), 'public/app-icons/')],
        symbolId: 'icon-[name]',
        svgoOptions: true,
      }),
    ],
    vue: {
      template: {
        compilerOptions: {
          isCustomElement: tag => {
            return ['tag'].includes(tag);
          },
        },
      },
    },
  },
});