Writing Content

Write Markdown with Nuxt Content, DocLayer and prebuilt utilities

Let's jump into what you're here for. Let's write some content.

Since DocLayer is built on top of Nuxt Content, any content you create should follow its conventions and rules, in return giving you full range of its powerful features. DocLayer Boilerplate (that you've just installed) is a ready-to-use application, that you can jump in and start writing. Even better, it's designed to be easily extended: by adding new content collections, creating new pages, using or building new components, utilities and helpers as needed. But remember, most of the tools and features that you might need, are probably already here. Read the documentation to get wider perspective of what's available out of the box.

This page is essential for understanding which internal features you can use while writing your content. It provides a high-level overview of what's available and what you might still need, whether that's something we can build or you can create yourself. Remember, we're always open to contributions in any area related to this project.

Please note that in some cases there may be overlap with the Nuxt Content documentation, but we've focused on highlighting the most important aspects, particularly those relevant to DocLayer.

Finally, whether you have a feature suggestion or want to contribute code, your input is greatly appreciated. Thank you in advance!

Use this app as an reference

The best advice before you start would be to use this docs application as a reference: browse through our repository and review the pages one by one. You'll find the best examples of how to define any type of content and control its appearance.

Collections

To get started writing content with DocLayer on top of Nuxt Content, you need to use collections. Collections are data models that the application. Before you'll write the first content pages and have them appear in the app structure, you need to define your collection data model. This is typically done in the content.config.ts file.

Please note that the content.config.ts file is automatically created each time you run the prepare script. This is one of several automations that occur during the process. Because this file is deleted before being regenerated, Nuxt Content may briefly report that it is missing before it is added again. When you start the app, this file will be in place and ready to use. You can disable this mechanism by setting the rootPrep.configs module option to false.

Default collections

By default, DocLayer includes the following predefined collections:

  • docs - for creating rich documentation(s),
  • blog - for publishing engaging articles,
  • landing - for welcoming your visitors and customers,
  • shared - data-type collection for shared components.

In your content.config.ts file, you'll see that these collections are imported directly from the module. This provides you with a ready-to-use data model for organizing your content.

It will look like this:

import { defineContentConfig } from '@nuxt/content';import { collections } from './.nuxt/doclayer/content.config';export default defineContentConfig({  collections,});

Each collection lends with its own dedicated schema, validated using zod. This ensures that whenever you work with your content’s data model, you’ll receive helpful suggestions and automatic validation for correctness. The schema covers not only standard page metadata like title and description, but also includes custom fields, fields for SEO, schema.org, and LLMs. More about schema and the full reference of it you can find here.

Predefined collections

Additionally, DocLayer provides couple of predefined collections, so you don't need to configure them in your content.config.ts file. These are:

  • articles - with blog collection schema,
  • guides - with docs collection schema,
  • tutorials - with docs collection schema.

Just create its corresponding folder in the content directory. For example, for articles collection, create content/articles directory and add your content files inside it. DocLayer will handle the rest.

Defining custom collection

You can easily define your own custom collection by extending the existing ones or build new from scratch, reusing the schemas provided by DocLayer. Here’s how you can do it:

import { defineContentConfig, defineCollection } from '@nuxt/content';import { collections, collectionSchema } from './.nuxt/doclayer/content.config';import * as zod from 'zod';export default defineContentConfig({  collections: {    ...collections,    myCollection: defineCollection({      type: 'page',      source: 'my-collection/**',      // reuse schema provided by DocLayer      schema: collectionSchema,      // or extend the existing one provided by DocLayer      schema: collectionSchema.extend({        customField: z.string().optional(),      }),      // or define your own schema      schema: z.object({        title: z.string().min(3),        description: z.string().min(10).max(160),        // ...      }),    }),  },});

Remember that any rule you apply should correspond with Nuxt Content conventions.

Collection pages

By default, all predefined collections in DocLayer are of type page. The only collection with a predefined path is landing, set to content/landing/index.md This serves as the main application entrypoint (the index). Any other collection you define will be treated as dynamic and resolved using Nuxt's dynamic routes mechanism.

This is how the page structure looks like:

pages/├── [...collection]/   # dynamic collection route, defined as /:collection(.*)*│   └── [...slug].vue  # dynamic page for dynamic collections (e.g., content/docs/01.getting-started/01.index.md)└── index.vue          # landing / home page (content/landing/index.md)

Now, if you create a new collection, let's say tutorials, adding new content/tutorials/my-first-tutorial.md file, it will be automatically available at the /tutorials/my-first-tutorial URL, resolved as an dynamic page.

Before creating new pages within a new folder structure, remember to register the new collection in the content.config.ts file.

Collection layouts

DocLayer offers two main layouts for your pages: default and landing.

  • The default layout is used for dynamic documentation pages. It includes features like a sidebar navigation, ToC and other tools to help users browse and read docs easily.
  • The landing layout is designed for landing pages, providing a clean, single-column design that focuses attention on the main content.

Layouts are automatically matched to collection based on type. This is how it looks like visually:

Documentation Page LayoutLanding Page Layout
Image
default
Image
landing

If you want to override or create your own, custom layout define one in the layouts directory. Remember that any new layout should be either assigned to existing or new application page.

Creating new content pages within the collection

Following Nuxt Content rules any content page you create should be placed within the content directory. Each collection should have its own subdirectory. For example, documentation pages should go into content/docs, blog articles into content/blog, and landing page into content/landing.

DocLayer Boilerplate provides a ready-to-use structure for your content, which you can find in the content directory. Here's how it looks like:

content/├── docs/│   ├── 01.getting-started/│   │   ├── 01-introduction.md│   │   ├── 02-installation.md│   │   └── ...│   └── ...├── blog/│   ├── 01-01-2025-article.md│   └── ...└── landing/    └── index.md

This structure exists only for demonstration purposes. You can modify it as needed, adding or removing folders and files to suit your project's requirements.

Nesting within collections

DocLayer currently supports up to 2 levels of nesting within your content collections. This means you can organize your content with one subdirectory inside each collection directory, but you cannot nest folders deeper than that.

For example:

  • ✅ content/docs/01.getting-started/01-introduction.md
  • ❌ content/docs/01.getting-started/01-introduction/extra.md

This 2-level structure helps DocLayer automatically generate clear, accordion-style navigation, making it easier for users to understand and traverse your documentation. If you choose not to use subdirectories, all your pages within a collection (such as blog) will appear as a flat list, under one accordion item.

Defining collection entrypoints

By default, DocLayer treats any index.md file as the main entry point for its collection. For example, content/landing/index.md acts as the homepage of your application. In the blog collection, an index.md file will serve as the main articles listing page, resulting in a user-friendly URL like /blog. In a nested structure such as docs, an index.md file inside a subdirectory (e.g., content/docs/01.getting-started/index.md) will represent the main page for that section, generating a URL like /docs/getting-started.

Please don't use path metadata field in frontmatter, as it may lead to unexpected behavior. It's not supported yet.

Finally, if you need to have full URL for the first page within the collection (for example /docs), you can create a dedicated file for it, like content/docs/01-getting-started/01-getting-started.md. This will be executed to the URL of /docs/getting-started/getting-started.

Excluding pages from navigation

If you want to exclude a specific page from appearing in the sidebar navigation, you can do so by adding navigation: false in the frontmatter of that page. This is useful for pages that are meant to be standalone or not part of the main documentation flow.

Ordering pages in navigation

To control the order of pages in the sidebar navigation, add numbers at the beginning of your folder and file names. Start with 0 or 1. If you have many pages, use two-digit numbers (like 01, 02, ..., 10, 11, etc.) to keep the sorting consistent and in the correct order. Not using numbers will lead to alphabetic sorting.

Using custom navigation labels

By default, the navigation link label is taken from the page's title. If you want the navigation to display a label different from the page title, add a navigation: label field in the frontmatter of that page. This is helpful when you want to customize how a page appears in the sidebar navigation.

---title: Getting Started with DocLayernavigation:  label: Getting Started with DocLayer---

Using navigation badges

To add a badge to a navigation item, include a navigation: badge field in the frontmatter of that page. This is useful when you want to show users the status of the page - for example, if it has been updated, is new, in development, or any other status you want to indicate.

---title: Getting Started with DocLayernavigation:  badge:    label: new    type: note  # or simple string value, defaults to the `info` type  badge: new---
type Badge =  | {      label: string;      type: 'info' | 'note' | 'warning' | 'alert';      size: 'sm' | 'md' | 'lg';      rounded: boolean;      icon: boolean;      glow: boolean;    }  | string;

Feature is handled by the DlBadge component, and supports the same types - use any of them as needed. You can also provide a simple string value for the badge label, and the type will be inferred automatically as info.

Writing content

It's all Markdown - plain, simple, and powerful. You can use any Markdown features you like. We've handled proper and consistent implementation for all types of content, from basic paragraphs to tables, images, and quotes, all the way to specialized internal components for extra functionality.

Markdownlint

To help you write well-formatted Markdown, the Boilerplate app has Markdownlint installed by default. If you're starting from scratch, we recommend adding it, as it can be a great and powerful addition to your workflow.

More about the internal setup of markdownlint, you can read here.

Frontmatter

Each content file starts with a Frontmatter section, enclosed by triple dashes: ---. This section contains metadata about the page, such as its title, description, and other relevant information. Here's an example of a frontmatter section:

---title: Introductiondescription: Welcome to DocLayer! This is the introduction to our documentation.---Your content goes here.

You can include various fields in the frontmatter, depending on your needs and the collection's schema. Common fields include:

  • title - the title of the page,
  • description - a brief description of the page's content.

These fields are required, as they will be used for page metadata and internal navigation. Additionally, we've made it easy to manage SEO, schema.org, and LLM-related metadata straight from the frontmatter. You can read more about defining metadata here.

Nuxt Content also provides a mechanism to define and use custom fields in your frontmatter, which you can access within the document using $doc.<field-name> handler. This is especially useful for repeating values. Though, remember that the field must be defined in the collection's schema to be recognized and validated.

Local data binding

We've set the initial _local object that you can use to define page-focused data, such as short repeatable strings or URLs that may be referenced multiple times on the page or with the DlLink or DlTooltip components. Here’s how you can define it:

---title: Your Page Titledescription: Your Page Description_local:  customProperty: custom value---My {{ $doc._local.customProperty }} will be displayed here.<!-- results in: My custom value will be displayed here. -->

With this approach, you don't need to add new data fields to the content schema for local, page-specific information - just use the _local object as needed.

Global data binding

For global data that you want to use across multiple pages, you can use the dl.inDocData object, which is defined within your application's configuration. This data is automatically injected into each page's context and can be accessed using $doc.<global-field-name>. Note that locally defined data always takes precedence over global data. More about the internal setup of dl.inDocData object, you can read here.

Headings

To organize and structure your content effectively, it's essential to use headings throughout your pages. Headings not only break up your content for better readability, but also help users navigate to specific sections and builds the Table of Contents (right-side panel).

DocLayer, together with its dedicated layout structure and Markdownlint, ensures a clear and accessible heading hierarchy, that supports both accessibility and SEO best practices. By default, the H1 heading is reserved for the main page title and appears at the top of it. All other headings should be used respectively within the page content. H2 and H3 headings are recognized as a key navigation points and are included in the page's Table of Contents (right-side panel of the content page). Additional headings (H4 and below) can be used as needed to further organization of your content - generating links - into sections and subsections.

Behind the scenes, each top-level H2 / H3 block is wrapped in a DlSection so the ToC can track the full section (not only the heading element). You keep writing plain Markdown - the wrapper is applied in memory before parse.

Search engines (like Google) no longer rely strictly on heading hierarchy for SEO, so headings can technically be used interchangeably. However, for the best accessibility and reading experience, it's still important to maintain the correct order - from H2 to H6 (within the content).

Components

Nuxt Content includes the MDC parser, allowing you to use both Vue and native components directly within your Markdown files.

In addition, DocLayer provides a unified set of built-in Vue components to help you enrich your content. These components are thoughtfully designed to work seamlessly with your Markdown, offering enhanced functionality and interactivity.

Below is a brief guide on how to use both types (block & inline) of components in your content, and to learn how to use any custom specific component please refer to the full list here.

There are two main component types you can use:

Block component

These are ideal for displaying larger or more complex content, such as code blocks, tabs, or callouts. To define them you need to use this type of notation within your Markdown files:

::block-componentYour component content goes here.::

This notation can be also used to define a native block components like div.

Everything what you put inside the block will be treated by Vue as a default slot, any named slot should be prefixed with #slot-name notation. Like this:

::block-componentYour default slot content goes here.#slot-nameYour named slot content goes here.::

On how to define components and their internals you can read within the MDC documentation and dedicated guide that can be found here.

Sometimes when you're nesting content components, you may encounter readability issues - especially if the parent component is very wide, making it difficult to see where it starts and ends. To solve this, simply use additional : delimiters to wrap the content of the parent component. Like this:

::block-componentYour component content goes here.:::block-componentYour component content goes here.:::::

Inline components

Best for simple, in-line elements like links or tooltips. It's also a perfect solution to use native HTML elements like code or p. This is how you can define these components:

:inline-component[slot content]:code[some code here]:p[some content inside paragraph]

Side note

Interestingly any inline component can technically be defined using block syntax as well. However, this is rarely practical, since inline components are only meant to handle the default slot and to be used directly within the content flow.

Defining properties

Finally, it's worth mentioning that all properties for MDC components should be added inside curly braces {}, written as strings and separated by spaces. Like this:

:inline-component[content]{first-prop="first prop data" second-prop="second prop data"}::block-component{first-prop="first prop data" second-prop="second prop data"}content::

Properties also include native attributes like style, class, or attr. However, these can only be applied to native components. Custom components have their own properties that are handled separately.

In most cases, values passed to properties should be strings. However, sometimes you may need to pass a boolean value. You can do this by providing the value as a string, like prop="true" or prop="false", or by using the boolean value directly, like prop=true or prop=false.

Defining dynamic properties

If you want to pass primitive dynamic data to a component property, you can define the property as such. For example:

---dynamicData: dynamic value---:inline-component[content]{:prop="dynamicData"}

However, any dynamic data defined locally (file-based) must be registered and set within the collection schema to be recognized, which can be confusing, often leading to unexpected behavior. To avoid that we've added a dedicated _local object that you can use to handle page-focused data. More about the internal setup of _local object, you can read here.

To ensure convenient, consistent, and fast usage, we provide an "extending props" mechanism that can process any dynamic data you define, whether global or local. This feature is a part of the DlWrapper component, which serves as the foundation for all custom content components. More about dynamic data setup within DlWrapper component, you can read here.

Resolving slots

Block and inline components resolve slots differently. Block components can use named slots, while inline components only support the default slot.

This is how it's resolved:

:inline-component[default slot resolves here]::block-componentdefault slot resolves here#namednamed slot resolves here::

It's worth noting that slots can resolve primitive dynamic data, such as strings and/or numbers. However, keep in mind that Vue's internal parsing may strip out special characters, so using advanced Markdown formatting is not recommended. Use it like this:

:inline-component[{{ $doc.title }}]

If you want to include Markdown formatting, it's best to use the DlFormat component within the slot, like this:

:inline-component[:dl-format[{{ $doc.title }}]]

Shared components

Sometimes, you may want to reuse the same component in multiple pages or collections. Since Nuxt Content does not natively support strictly shared Markdown components, we provide the DlRenderer component, which lets you render any shared segment of Markdown code.

Recipes

There may be situations where you want to extend Markdown's capabilities, but the solution isn't immediately obvious. Here are some ideas to help you make your content even better.

Displaying code within tables

Formatting tables in Markdown can be tricky, especially if you want more control over the content inside each cell, like adding code. Inline components are a great solution for this. For example, if you want to include a code snippet inside a table cell without too much extra markup, you can do something like this:

<!-- header of your table -->| :dl-code-inline{code="Record<string, string>"} | table cell content |<!-- the rest of your table -->

This approach is especially useful when defining types - such as unions - where the | separator would otherwise break the table formatting. On the other hand you can always escape this separator by using the \ character.

You can do the same also with native HTML elements. Use tags like p, span, or any other text/inline elements you need. Style them (with style prop) within the table accordingly, they will be properly rendered inside the Markdown table. Finally, it's also possible to use any of DocLayer's inline components.

Displaying block-level components within the table cells

Additionally, to display code blocks within table cells, you can use the DlRenderer component together with a shared Markdown component (placed in the _shared directory) that contains the DlCode block. Here’s how you can do it:

::dl-code```tsconst value = 'some value';```::
| :dl-renderer[code-component] | table cell content |

Making table's first column sticky

Sometimes when you're using tables for comparisons and the content exceeds the normal table width, it can be difficult to keep track of the first column, which usually contains the item definition. In these cases, it's helpful to make the first column sticky so it stays visible while you scroll horizontally.

To achieve that just leave the first row heading cell empty. Like this:

| | table heading cell content |

style instead of class for native components

Sometimes when you're using native inline components, like div or p, you may want to add some styling to them. Since Tailwind CSS is available, you might be tempted to use utility classes. However, during rendering, these classes may not always be recognized or applied - especially if you use custom values for e.g., sizes, colors, etc. Instead of using classes, use plain inline styles, like this:

:div[Some content inside your div block]{style="width: 10rem;"}

VSCode Tricks

While creating new content, we've found several helpful workflow tips that can make working with content more efficient and effective.

Content soft wrap

When you start with DocLayer Boilerplate, VSCode settings may have long line wrapping disabled. This often happens due to formatting issues with elements like tables. To quickly enable word wrapping for improved readability - especially for long paragraphs or complex table layouts - use the Alt (Option on Mac) + Z keyboard shortcut.

Markdown breadcrumbs

When editing large documentation files or nested content, it's useful to quickly understand where you are in the document structure. VSCode displays breadcrumbs at the top of the editor for Markdown files, outlining the current heading hierarchy.

If breadcrumbs aren't visible, you can enable them via:

  1. Menu: Go to View → Show Breadcrumbs.
  2. Command Palette: Open with Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (Mac), you'll see the top-located panel, then search for > View: Toggle Breadcrumbs.

Breadcrumbs help you navigate your Markdown headings efficiently by letting you click any part of the path to quickly jump between sections or headings in your file.

Support for Tailwind's custom utilities

To ensure full editor support and autocomplete for all custom Tailwind CSS utilities and directives used in this project, a .vscode/tailwind.json file is included with DocLayer Boilerplate. You don’t need to manually edit or use this file during content authoring - instead, it exists so VSCode can recognize project-specific extensions like @utility, @apply or custom design tokens when you're editing CSS and other files that use Tailwind syntax.

You don't have to manage or update .vscode/tailwind.json yourself - it's maintained in the project so the editor can offer a seamless content and styling workflow with all custom Tailwind rules available.

Reloading TypeScript server

If you find that editor features like autocompletion or type-checking aren't working correctly - especially after updating dependencies, making changes to types, or installing new modules - you may need to reload the TypeScript server in VSCode. This ensures you get up-to-date intellisense and error reporting for your Markdown or code files.

To reload the TypeScript server:

Open command palette

Open the command palette with Ctrl + Shift + P (or Cmd + Shift + P on Mac). You'll see the top-located panel.

Restart server

Start typing “> TypeScript: Reload Project” or “> TypeScript: Restart TS server” and select the relevant command from the dropdown.

Step 0 of 0

You should notice that autocompletion and type-checking are restored almost immediately. This is particularly helpful after major edits to .d.ts files or when new packages are introduced. The procedure might be also valid after restarting the app after rebuilding path or component registries.