Skip to content

docsector/docsector-reader

Repository files navigation

docsector-logo

Docsector Reader πŸ“–

A documentation rendering engine built with Vue 3, Quasar v2 and Vite.

npm version License

Transform Markdown content into beautiful, navigable documentation sites β€” with i18n, syntax highlighting, dark/light mode, and anchor navigation.


✨ Features

  • πŸ“ Markdown Rendering β€” Write docs in Markdown, rendered with syntax highlighting (Prism.js)
  • 🌍 Internationalization (i18n) β€” Multi-language support with HJSON locale files and per-page translations
  • πŸŒ— Dark/Light Mode β€” Automatic theme switching with Quasar Dark Plugin
  • πŸ”— Anchor Navigation β€” Right-side Table of Contents tree with scroll tracking
  • πŸ”Ž Search β€” Menu search across all documentation content and tags
  • πŸ“± Responsive β€” Mobile-friendly with collapsible sidebar and drawers
  • 🏷️ Status Badges β€” Mark pages as done, draft, or empty with visual indicators
  • ✏️ Edit on GitHub β€” Direct links to edit pages on your repository
  • πŸ“Š Translation Progress β€” Automatic translation percentage based on header coverage
  • βš™οΈ Single Config File β€” Customize branding, links, and languages via docsector.config.js

πŸš€ Quick Start

πŸ“¦ Install

npm install @docsector/docsector-reader

πŸ—οΈ Scaffold a new project

npx docsector init my-docs
cd my-docs
npm install

This creates a minimal project with quasar.config.js, docsector.config.js, src/pages/, src/i18n/, and public/ β€” all powered by the docsector-reader engine.

πŸ’» Development

npx docsector dev
# or
npx quasar dev

🏭 Production Build

npx docsector build
npx docsector serve    # Preview production build

πŸ“ Architecture β€” Library Mode

Docsector Reader works as a rendering engine: it provides the layout, components, router, store, and boot files. Consumer projects supply only their content (pages, i18n, config, assets).

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Consumer project (your-docs/)                        β”‚
β”‚  β”œβ”€β”€ docsector.config.js   ← branding, links, langs  β”‚
β”‚  β”œβ”€β”€ quasar.config.js      ← thin wrapper            β”‚
β”‚  β”œβ”€β”€ src/pages/            ← Markdown + route defs    β”‚
β”‚  β”œβ”€β”€ src/i18n/             ← language files + tags    β”‚
β”‚  └── public/               ← logo, images, icons     β”‚
β”‚                                                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  @docsector/docsector-reader (engine)         β”‚    β”‚
β”‚  β”‚  β”œβ”€β”€ App.vue, router, store, boot files       β”‚    β”‚
β”‚  β”‚  β”œβ”€β”€ DPage, DMenu, DH1–DH6, DefaultLayout    β”‚    β”‚
β”‚  β”‚  β”œβ”€β”€ composables (useNavigator)               β”‚    β”‚
β”‚  β”‚  └── CSS, Prism.js, QZoom                     β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Consumer quasar.config.js

The consumer's Quasar config is a thin wrapper around the factory:

import { configure, createQuasarConfig } from '@docsector/docsector-reader/quasar-factory'

export default configure(() => {
  return createQuasarConfig({
    projectRoot: import.meta.dirname,

    // Optional: consumer-specific boot files (resolved from src/boot/)
    boot: ['qmediaplayer'],

    // Optional: PWA manifest overrides
    pwa: {
      name: 'My Docs',
      short_name: 'Docs',
      theme_color: '#027be3'
    },

    // Optional: extra Vite plugins
    vitePlugins: [],

    // Optional: extend Vite config further
    extendViteConf (viteConf) {
      // custom aliases, plugins, etc.
    }
  })
})

How aliases work

Alias Standalone Consumer mode
components project src/components/ package src/components/
layouts project src/layouts/ package src/layouts/
boot project src/boot/ package src/boot/
composables project src/composables/ package src/composables/
css project src/css/ package src/css/
stores project src/store/ package src/store/
pages project src/pages/ consumer src/pages/
src/i18n project src/i18n/ consumer src/i18n/
docsector.config.js project root consumer root
@docsector/tags project src/i18n/tags.hjson consumer src/i18n/tags.hjson

βš™οΈ Configuration (docsector.config.js)

export default {
  branding: {
    logo: '/images/logo/my-logo.png',
    name: 'My Project',
    version: 'v1.0.0',
    versions: ['v1.0.0', 'v0.9.0']
  },

  links: {
    github: 'https://github.com/org/repo',
    discussions: 'https://github.com/org/repo/discussions',
    chat: 'https://discord.gg/invite',
    email: 'contact@example.com',
    changelog: 'https://github.com/org/repo/releases',
    roadmap: 'https://github.com/org/repo/blob/main/ROADMAP.md',
    sponsor: 'https://github.com/sponsors/user',
    explore: [
      { label: '🌟 Related Project', url: 'https://github.com/org/related' }
    ]
  },

  github: {
    editBaseUrl: 'https://github.com/org/repo/edit/main/src/pages'
  },

  languages: [
    { image: '/images/flags/united-states-of-america.png', label: 'English (US)', value: 'en-US' },
    { image: '/images/flags/brazil.png', label: 'PortuguΓͺs (BR)', value: 'pt-BR' }
  ],

  defaultLanguage: 'en-US'
}

🌍 Internationalization

i18n setup (src/i18n/index.js)

Consumer projects use the buildMessages helper from the engine:

import { buildMessages } from '@docsector/docsector-reader/i18n'

const langModules = import.meta.glob('./languages/*.hjson', { eager: true })
const mdModules = import.meta.glob('../pages/**/*.md', { eager: true, query: '?raw', import: 'default' })

import boot from 'pages/boot'
import pages from 'pages'

export default buildMessages({ langModules, mdModules, pages, boot })

Language files

Place HJSON locale files in src/i18n/languages/:

src/i18n/languages/en-US.hjson
src/i18n/languages/pt-BR.hjson

Search tags (src/i18n/tags.hjson)

Provide search keywords per route and locale for menu search:

{
  "en-US": {
    "/manual/my-section/my-page": "keyword1 keyword2 keyword3"
  }
  "pt-BR": {
    "/manual/my-section/my-page": "palavra1 palavra2 palavra3"
  }
}

πŸ“ Consumer Project Structure

my-docs/
β”œβ”€β”€ docsector.config.js        # Branding, links, languages
β”œβ”€β”€ quasar.config.js           # Thin wrapper using createQuasarConfig()
β”œβ”€β”€ package.json
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ index.js           # Page registry (routes + metadata)
β”‚   β”‚   β”œβ”€β”€ boot.js            # Boot page data
β”‚   β”‚   β”œβ”€β”€ guide/             # Guide pages (.md files)
β”‚   β”‚   └── manual/            # Manual pages (.md files)
β”‚   β”œβ”€β”€ i18n/
β”‚   β”‚   β”œβ”€β”€ index.js           # Uses buildMessages() from engine
β”‚   β”‚   β”œβ”€β”€ tags.hjson         # Search keywords per route/locale
β”‚   β”‚   └── languages/         # HJSON locale files
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── app.sass           # Optional overrides (imports engine CSS)
β”‚   └── boot/                  # Consumer-specific boot files
β”‚       └── qmediaplayer.js    # Example: custom Quasar extension
└── public/
    β”œβ”€β”€ images/logo/           # Project logo
    β”œβ”€β”€ images/flags/          # Locale flag images
    └── icons/                 # PWA icons

πŸ“„ Adding Pages

1️⃣ Register in src/pages/index.js:

export default {
  '/manual/my-section/my-page': {
    config: {
      icon: 'description',
      status: 'done',        // 'done' | 'draft' | 'empty'
      type: 'manual',        // 'guide' | 'manual'
      menu: {
        header: { label: '.my-section', icon: 'category' }
      },
      subpages: { showcase: false, vs: false }
    },
    data: {
      'en-US': { title: 'My Page' },
      'pt-BR': { title: 'Minha PΓ‘gina' }
    }
  }
}

2️⃣ Create Markdown files:

src/pages/manual/my-section/my-page.overview.en-US.md
src/pages/manual/my-section/my-page.overview.pt-BR.md

πŸ–₯️ CLI Commands

docsector init <name>          # Scaffold a new consumer project
docsector dev                  # Start dev server (port 8181)
docsector dev --port 3000      # Custom port
docsector build                # Build for production (dist/spa/)
docsector serve                # Serve production build
docsector help                 # Show help

πŸ”Œ Exports

Import path Export Description
@docsector/docsector-reader/quasar-factory createQuasarConfig() Config factory for consumer projects
@docsector/docsector-reader/quasar-factory configure() No-op wrapper (avoids needing quasar dep)
@docsector/docsector-reader/i18n buildMessages() Build i18n messages from globs + pages
@docsector/docsector-reader/i18n filter() Filter i18n messages by locale

πŸ› οΈ Tech Stack

Technology Purpose
Vue 3 Composition API + <script setup>
Quasar v2 UI framework
@quasar/app-vite Vite-based Quasar build
Vuex 4 State management
vue-i18n 9 Internationalization
markdown-it Markdown parsing
Prism.js Syntax highlighting
HJSON Human-friendly JSON for locale files

🀝 Contributing

Contributions are welcome! Please open an issue or submit a pull request.


πŸ“ƒ License

Copyright (c) Rodrigo de Araujo Vieira

MIT License

Releases

No releases published