Skip to main content
Docus provides Vue composables for common documentation functionality. These composables are auto-imported and available in all components.

useSeo

Comprehensive SEO setup including meta tags, canonical URLs, hreflang tags, and JSON-LD structured data. Location: app/composables/useSeo.ts

Usage

<script setup lang="ts">
const { data: page } = await useAsyncData('page', () => 
  queryContent('/docs/introduction').findOne()
)

useSeo({
  title: page.value.title,
  description: page.value.description,
  type: 'article',
  publishedAt: page.value.publishedAt,
  modifiedAt: page.value.modifiedAt,
  breadcrumbs: [
    { title: 'Home', path: '/' },
    { title: 'Docs', path: '/docs' },
    { title: page.value.title, path: page.value._path }
  ]
})
</script>

Options

title
string | Ref<string>
required
Page title for meta tags and Open Graph.
description
string | Ref<string>
required
Page description for meta tags and Open Graph.
type
'website' | 'article'
default:"article"
Page type for og:type meta tag.
  • article - For documentation pages (includes Article schema)
  • website - For landing pages (includes WebSite schema)
ogImage
string | Ref<string>
Custom Open Graph image URL (absolute URL).
publishedAt
string | Ref<string>
Published date in ISO 8601 format for Article schema.
modifiedAt
string | Ref<string>
Last modified date in ISO 8601 format for Article schema.
breadcrumbs
BreadcrumbItem[] | Ref<BreadcrumbItem[]>
Breadcrumb items for BreadcrumbList JSON-LD schema.Each item should have:
  • title (string) - Breadcrumb label
  • path (string) - Breadcrumb URL path

Features

Meta Tags:
  • Title and description
  • Open Graph tags (og:title, og:description, og:type, og:url, og:locale)
  • Twitter Card tags
  • Canonical URL
Internationalization:
  • Automatic hreflang tags for all locales
  • x-default hreflang pointing to default locale
  • og:locale set to current locale
Structured Data (JSON-LD):
  • Article schema for documentation pages
  • WebSite schema for landing pages
  • BreadcrumbList schema for navigation
  • Publisher information from site config

Example with Full Options

<script setup lang="ts">
useSeo({
  title: 'Introduction to Docus',
  description: 'Learn how to build beautiful documentation with Docus',
  type: 'article',
  ogImage: 'https://docus.dev/og-images/introduction.png',
  publishedAt: '2024-01-15T10:00:00Z',
  modifiedAt: '2024-03-20T15:30:00Z',
  breadcrumbs: [
    { title: 'Home', path: '/' },
    { title: 'Documentation', path: '/docs' },
    { title: 'Getting Started', path: '/docs/getting-started' },
    { title: 'Introduction', path: '/docs/getting-started/introduction' }
  ]
})
</script>

useLogoAssets

Manage logo assets with copy, download, and context menu functionality. Location: app/composables/useLogoAssets.ts

Usage

<script setup lang="ts">
const {
  hasLogo,
  currentLogoUrl,
  headerLightUrl,
  headerDarkUrl,
  logoAlt,
  contextMenuItems,
  copyLogo,
  downloadLogo
} = useLogoAssets()
</script>

<template>
  <img 
    v-if="hasLogo" 
    :src="currentLogoUrl" 
    :alt="logoAlt" 
  />
  <button @click="copyLogo">Copy Logo</button>
  <button @click="downloadLogo">Download Logo</button>
</template>

Returned Properties

Whether a logo is configured in app.config.
displayMode
Ref<'logo' | 'wordmark'>
Current display mode for the header.
currentLogoUrl
Ref<string>
Current logo URL based on color mode.
headerLightUrl
Ref<string>
Logo URL for light mode header.
headerDarkUrl
Ref<string>
Logo URL for dark mode header.
hasWordmark
Ref<boolean>
Whether a wordmark is configured.
currentWordmarkUrl
Ref<string>
Current wordmark URL based on color mode.
faviconUrl
Ref<string>
Favicon URL from configuration.
logoAlt
Ref<string>
Alt text for the logo.
contextMenuItems
Ref<ContextMenuItem[][]>
Context menu items for the logo (copy, download, brand assets).

Methods

Copy logo SVG to clipboard (only works for SVG logos).Shows success/error toast notification.
Download logo file.Shows success toast notification.
copyWordmark
() => Promise<void>
Copy wordmark SVG to clipboard (only works for SVG wordmarks).
downloadWordmark
() => Promise<void>
Download wordmark file.
copyTextToClipboard
(text: string) => Promise<boolean>
Utility function to copy text to clipboard.
fetchSvgContent
(url: string, name: string) => Promise<string | null>
Fetch and normalize SVG content from a URL.

Features

Automatic SVG Normalization:
  • Replaces hard-coded colors with currentColor
  • Adds id and title elements for accessibility
  • Optimizes SVG for embedding
Context Menu Integration:
  • Copy logo (SVG only)
  • Copy wordmark (SVG only)
  • Download logo
  • Download wordmark
  • Link to brand assets page
Toast Notifications:
  • Success/error feedback for copy operations
  • Download confirmations

useDocusI18n

Unified internationalization interface that works with or without the @nuxtjs/i18n module. Location: app/composables/useDocusI18n.ts

Usage

<script setup lang="ts">
const { 
  isEnabled, 
  locale, 
  locales, 
  t, 
  localePath, 
  switchLocalePath 
} = useDocusI18n()
</script>

<template>
  <div>
    <p>Current locale: {{ locale }}</p>
    <p>{{ t('welcome.message') }}</p>
    
    <NuxtLink 
      v-for="loc in locales" 
      :key="loc.code"
      :to="switchLocalePath(loc.code)"
    >
      {{ loc.name }}
    </NuxtLink>
  </div>
</template>

Returned Properties

isEnabled
Ref<boolean>
Whether i18n is enabled in the project.
locale
Ref<string>
Current locale code (e.g., 'en', 'fr').
locales
LocaleObject[]
Array of configured locales with code and name properties.Returns empty array if i18n is not enabled.
t
(key: string) => string
Translation function.When i18n is disabled, uses fallback locale messages from Docus.
localePath
(path: string) => string
Generate localized path for a given route.When i18n is disabled, returns the path unchanged.
switchLocalePath
(locale: string) => string
Get the path for switching to a different locale.When i18n is disabled, returns undefined.

Features

Graceful Fallback:
  • Works without @nuxtjs/i18n module
  • Provides consistent API regardless of i18n configuration
  • Built-in translations for UI elements
Type Safety:
  • Full TypeScript support
  • Compatible with @nuxtjs/i18n types

Translation Keys

Built-in translation keys available:
// Logo actions
t('logo.copyLogo')
t('logo.copyWordmark')
t('logo.downloadLogo')
t('logo.downloadWordmark')
t('logo.brandAssets')
t('logo.logoCopied')
t('logo.wordmarkCopied')
t('logo.copyLogoFailed')
t('logo.copyWordmarkFailed')
t('logo.logoDownloaded')
t('logo.wordmarkDownloaded')

useAssistant

Control the AI assistant panel state and functionality. Location: layer/modules/assistant/runtime/composables/useAssistant.ts

Usage

<script setup lang="ts">
const { 
  isEnabled,
  isOpen, 
  isExpanded,
  messages,
  pendingMessage,
  faqQuestions,
  open, 
  close, 
  toggle,
  toggleExpanded,
  clearMessages,
  clearPending
} = useAssistant()

// Open assistant with an initial question
function askQuestion(question: string) {
  open(question)
}

// Open assistant and clear previous conversation
function startNewConversation() {
  open(undefined, true)
}
</script>

<template>
  <div>
    <button v-if="isEnabled" @click="toggle">
      {{ isOpen ? 'Close' : 'Open' }} Assistant
    </button>
    
    <p v-if="isOpen">
      Panel width: {{ panelWidth }}px
      Expanded: {{ isExpanded }}
    </p>
  </div>
</template>

Returned Properties

isEnabled
Ref<boolean>
Whether the AI assistant is enabled in the configuration.
isOpen
Ref<boolean>
Whether the assistant panel is currently open.
isExpanded
Ref<boolean>
Whether the assistant panel is in expanded mode (520px vs 360px).
isMobile
Ref<boolean>
Whether the current viewport is mobile (max-width: 767px).
panelWidth
Ref<number>
Current panel width in pixels (360 for compact, 520 for expanded).
shouldPushContent
Ref<boolean>
Whether the assistant panel should push content aside (true when open on desktop).
messages
Ref<UIMessage[]>
Array of chat messages in the current conversation.
pendingMessage
Ref<string | undefined>
Message waiting to be sent when the panel opens.
faqQuestions
Ref<FaqCategory[]>
FAQ questions configured in app.config.ts, normalized to category format.Automatically handles localized FAQ questions based on current locale.

Methods

open
(initialMessage?: string, clearPrevious?: boolean) => void
Open the assistant panel.Parameters:
  • initialMessage (optional) - Message to send when panel opens
  • clearPrevious (optional, default: false) - Clear previous messages before opening
close
() => void
Close the assistant panel.
toggle
() => void
Toggle the assistant panel open/closed state.
toggleExpanded
() => void
Toggle between compact (360px) and expanded (520px) panel widths.
clearMessages
() => void
Clear all messages from the current conversation.
clearPending
() => void
Clear the pending message without sending it.

Features

Responsive Behavior:
  • Automatically detects mobile viewports
  • Adjusts panel width based on expanded state
  • Only pushes content on desktop viewports
Localization Support:
  • Handles localized FAQ questions
  • Falls back to default locale if current locale not available
  • Normalizes FAQ format (string arrays or category objects)
State Management:
  • Uses Nuxt’s useState for persistent state across navigation
  • Shared state between components
  • Reactive updates

Example: Custom Assistant Trigger

<script setup lang="ts">
const { isEnabled, open, faqQuestions } = useAssistant()

function askFaq(question: string) {
  open(question, true) // Open with question and clear previous messages
}
</script>

<template>
  <div v-if="isEnabled">
    <h3>Frequently Asked Questions</h3>
    <div v-for="category in faqQuestions" :key="category.category">
      <h4>{{ category.category }}</h4>
      <button 
        v-for="question in category.items" 
        :key="question"
        @click="askFaq(question)"
      >
        {{ question }}
      </button>
    </div>
  </div>
</template>

Type Definitions

UseSeoOptions

interface UseSeoOptions {
  title: MaybeRefOrGetter<string | undefined>
  description: MaybeRefOrGetter<string | undefined>
  type?: MaybeRefOrGetter<'website' | 'article'>
  ogImage?: MaybeRefOrGetter<string | undefined>
  publishedAt?: MaybeRefOrGetter<string | undefined>
  modifiedAt?: MaybeRefOrGetter<string | undefined>
  breadcrumbs?: MaybeRefOrGetter<BreadcrumbItem[] | undefined>
}
interface BreadcrumbItem {
  title: string
  path: string
}

Build docs developers (and LLMs) love