The DlLink inline component generates links using path markers that resolves to URLs from an auto-generated or a custom path registry. It ensures consistent, maintainable linking across your application while supporting hashes, targets, and inline styling.
The Why
You probably know that Markdown can easily display links using simple syntax. However, when writing documentation, we often need to use the same links in multiple places, or link to different pages and sections throughout the content. Keeping these links consistent - both in how they look and where they point can be difficult and time-consuming, especially if a URL or label changes.
That’s why we created the DlLink component: to make linking fast, intuitive, and maintainable, so you don’t have to update multiple pages or change every instance of a link manually. We strongly recommend using this component across your content, as it can handle all types of links with better control over their behavior and global appearance.
Features
- 🧭 marker-based URLs via
$path-marker - 🌐 global registry for centralized link management
- 🧠 smart caching for link data resolutions
- #️⃣ optional hash and path resolving for the URL
- 📧 email link(s) support
- 🧩 theme-friendly visual adjustments
- ↗️ external link indicator
- ⚠️ extensive error reporter
Usage
DlLink resolves URLs using an automatically generated registry. This registry is built by a DocLayer module that scans your content tree and assigns unique markers to each document's URL. All predefined markers can be used with the DlLink component and are validated with markdownlint as you write content.
Markers are built with the following pattern:
$[collection-name]-[folder-name]-[page-name].
For example:
$docs-components(index page)$docs-guidelines-writing-content
Use the :dl-link[...] as an inline component with a path marker provided as the default slot, and the human-friendly label set via the label prop.
Result: you can read here
With a hash
Append a hash to jump to a specific section of the target page.
Result: defining properties
With a new tab
Use blank target property to open the link in a new tab.
Result: open an issue
With a local data
DlLink component can also handle locally (per page) defined URLs. In your Frontmatter section, you can define custom data with the _local property - add any custom key with a URL. To use this URL in the link component pass it using $doc handler and let the component know it should use the local link. For example:
Thanks to this notation, if you have multiple links on the same page that only need to be used there, and you don't need to define them globally in the dl.pathMap array - this solution is sufficient.
Result: local link to Nuxt documentation
Local parameters manipulation
Sometimes, on the same page, you may want to manipulate the URL with additional parameters, e.g. to open a modal or a popup. To do this, you can add them to the path property. Like this:
The parameter will then be added to the URL.
Additionally, if the URL has an attached hash, it will be preserved. If you want to prevent the page from scrolling to a section, set the hash to $unset. For example:
We use this solution to open the AI Assistant from the link (check the URL).
With custom URL path
When using custom URLs, you can add dedicated paths to avoid repeating pathMap records for the same domain. For example, you can add a record for the Vue documentation base URL, and then define dedicated paths for specific pages or sections as needed. Path can be defined also with hash.
Result: Vue.js introduction
Custom paths and URLs
You can define external URL or override the auto-generated path by adding a custom record in your app.config.ts under dl.pathMap. When a custom record with the same marker (as auto-generated) is present, it takes precedence.
Resolving labels
Because we don't know how you would label the internal pages links, you must provide a label property for DlLink component when using the auto-generated paths - registry markers. In contrast, when you define custom path objects, you can set a global label that will be reused throughout the application.
If you specify a label property on the DlLink component, it will override any globally defined label for that link. Finally, to set a global label for a predefined (auto-generated) path, simply create a new custom path object using the same marker and specify your desired label.
TypeScript compiler will suggest you all of the predefined markers.
Global Configuration
The only thing that needs to be done globally is to register your custom paths in the dl.pathMap array inside your app.config.ts file.
Required configuration at runtime
Additionally, note that for efficiency, the registry is generated only once when prepare process is executed. If you add new pages or change existing page names, you need to re-run the prepare process to update the registry.
Props
Here are the properties you can use with the DlLink component. Each property should be set on an individual component instance; they do not affect the global configuration. More about defining properties in MDC components you can read here.
| name | type | default | description |
|---|---|---|---|
lazy | boolean | undefined | Whether to lazy load the component. |
label | string | undefined | Human-readable link text. Required when using a registry marker. |
marker | keyof pathMapRegistry | undefined | Path marker key used to resolve the URL. Usually provided via slot: |
path | string | undefined | Optional URL path to append to the resolved URL. |
hash | string | '$unset' | undefined | Optional hash to append to the resolved URL (define without |
local | boolean | false | Whether to use a locally defined URL. |
suffix | string | undefined | Additional character(s) to display together with the link label. Works as a suffix. |
target | 'blank' | 'self' | 'self' | Browser target for the link. |
iui | Record<string, string> | undefined | Special property dedicated to inline components, can be used to add TW classes for certain component markup elements. |
Slots
| name | description |
|---|---|
default | The |
Styling
Styling from Markdown
Every DocLayer component can be styled directly within your Markdown file using dedicated slot/property configuration. This allows you to customize the appearance of the component's markup elements without modifying global styles. More about components styling you can read here.
Below you'll find the default set of Tailwind classes for the component's dedicated markup elements.
CSS Variables
Here is a set of CSS variables you can use to customize the appearance of the DlLink component globally. More about theming and styling with CSS variables, you can read here.
In companion to CSS variables links are styled globally using the u-link-style utility class. More about text-like utility classes, you can read here.
Caching
To optimize performance and avoid unnecessary recomputation, the DlLink component caches resolved link data. When a link is rendered, its resolved URL and label are stored in a local state cache. This means that if the same link is rendered again, the component will reuse the cached data instead of recalculating it (fetching from registry).
