Strip .md extension
Opt-in top-level config that removes .md or .mdx suffixes from internal link hrefs at build time.
stripMdExt is an opt-in top-level zfb.config.ts field, not a markdown.features entry. It defaults to false; when omitted or set to false, author-written .md and .mdx hrefs are preserved.
When enabled, StripMdExtensionPlugin removes the .md or .mdx suffix from internal link href values and appends a trailing slash, so links authored as [page](. produce clean output URLs like ..
What it does
In the hast phase, the plugin walks every <a> element. For each internal link whose path ends with .md or .mdx:
Strips the extension.
Appends a trailing
/to the stripped path.Preserves the query string and fragment after the slash.
The plugin touches internal relative and root-relative paths. Absolute URLs (https:), anchor-only links (#section), non-link elements, and hrefs with non-markdown file extensions are left unchanged. In trailing-slash mode, extensionless relative hrefs such as . and . also become . and ..
Config
Enable it at the top level:
import { defineConfig } from "zfb/config";
export default defineConfig({
stripMdExt: true,
});The plugin runs after ResolveLinksPlugin when both are configured, so it sees already-resolved paths before cleaning up any remaining markdown extensions.
Example
See [setup](./installation.mdx#requirements) for details.With stripMdExt: true, produces:
<p>See <a href="./installation/#requirements">setup</a> for details.</p>With stripMdExt: false or an omitted config field, the authored . href is preserved.
See also
Resolve links — runs before this plugin to normalise the target path.