Globals

DocLayer’s global instances for easy and quick access

Global Instance

For convenient and universal access, DocLayer exposes a global instance available on both the server and client sides. This can be especially useful when building features where the Vue or Nuxt context might not be directly available. Since the global instance is accessible everywhere, you can use it confidently throughout your application.

To reach DocLayer's globally exposed internals, simply use globalThis.__DL__.

const instance = globalThis.__DL__;

The global instance (globalThis.__DL__) will expose the following properties for you to access from anywhere in your application - whether on the server or client: appConfig, adapterData, utils (utilLogger, utilLogMessage).

Global Instance - DocLayer.dev
Global Instance Object

Logger

We've exposed a single global instance of logger, powered by Consola. For consistent and readable logging, this logger is used throughout the entire codebase. We recommend using this instance whenever you need to log messages, rather than creating new logger instances. Logging will be even more consistent when you combine it with the utilLogMessage utility. You can access it as shown below:

import { utilLogger, utilLogMessage } from '@vuehouse/dl/exports';// stand-aloneutilLogger.warn('Something went wrong');utilLogger.info('This went great');// with utilLogMessageutilLogger.warn(utilLogMessage(['Something went wrong', 'customSource', 'customTag']));// results in: ⚠ [customtag: customSource] Something went wrong

The logger uses a globally defined tag by default, which can be set using the DL_TAG environment variable. This means you don't need to specify a tag each time you use the logger. More about defining global metadata, you can read here.

Exports

The DocLayer package provides several entry points that expose utilities, types, and configuration objects. You can access them as shown below - we've listed your options here:

@vuehouse/dl/exports

This entry point primarily exports utilities, macros, and adapters. All of these are fully tree-shakeable and work independently. You can find detailed documentation for each export on its dedicated page, where we additionally note how to import and use each one.

import {  useAdapterData,  defineDoclayerAdapter,  defineDoclayerAppConfig,  defineDoclayerComponentUi,  utilUID,  utilSlugGen,  utilMDToHTML,  utilObjectParser,  utilBooleanString,  utilEmailParser,  utilCastItem,  utilThrottle,  utilLogMessage,  utilWarnPatternCheck,  utilTWC,  utilLogger,  utilWindowWidth,  utilStaticTransformers,  resendAdapter,  substackAdapter,  gaAdapter, // or googleAnalyticsAdapter} from '@vuehouse/dl/exports';

@vuehouse/dl/types

All utility types documented on the types page are available from this entrypoint. Simply import them by name from the package as needed.

import type { UtilityType, ... } from '@vuehouse/dl/types';

Packages

Below is a list of packages that are part of the DocLayer ecosystem, along with a brief description of their responsibilities and guidance on how to use them.

License
Description

Core
@vuehouse/dl
Nuxt Module

MIT

The main DocLayer package. Nuxt module that extends a standard Nuxt application, enabling you to build on top of DocLayer.

Search
@vuehouse/dl-search
Nuxt Module

MIT

Search module enables text-based search and AI assistance within your content. It is tightly integrated with DocLayer, providing a seamless search experience in module-powered applications.

Markdownlint Rules
@vuehouse/dl-mdl-rules
Plugin

MIT

A set of markdownlint rules designed to improve your writing experience when working with DocLayer's content. The ruleset is currently small but will expand as DocLayer evolves.

ESLint Configuration
@vuehouse/eslint-config

MIT

Globally defined ESLint configuration used across the DocLayer monorepo. It provides rules for both module-based applications and internal Nuxt components.

Vercel Deployment
@vuehouse/dl-vercel
Nuxt Module

MIT

A complementary package for Vercel deployment that ensures the correct platform-specific configuration and final build structure. It is especially super useful if you want to work with Vercel's CLI and CI/CD pipelines.

CLI
@vuehouse/dl-cli
Command Line Interface

MIT

A command-line interface for DocLayer. It provides a set of commands to help you manage your DocLayer-based application.

AI Kit
@vuehouse/dl-ai-kit
Nuxt Module

MIT

Complementary package enabling AI capabilities for DocLayer. Providing advanced Chat interface, session-aware assistance, data storage, and retrieval workflows.