Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>MDShieldNew to Visual Studio Code? Get it now.
MDShield

MDShield

Summerbud

|
72 installs
| (0) | Free
Guard your markdown/mdx file's frontmatter/meta with this vscode extension.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

MD Shield

Guard your markdown/mdx file's frontmatter/meta with vscode extension and in-project pre-build script.

What is this

MDShield will highlight the type error of your markdown frontmatter. And you could use MDShield as a pre-build script to ensure every markdown file's frontmatter in your project is correct.

How to use

  1. Add mdshield.config.mjs|js at the root of your project.
// mdshield.config.mjs
const config = {
  strict: true,
  meta: "frontmatter",
  types: {
    regular: {
      title: "string | 123 | false | null",
      description: "string",
      },
    },
  },
};

export default config;
// mdshield.config.js
module.export = {
  strict: true,
  meta: "frontmatter",
  types: {
    regular: {
      title: "string | 123 | false | null",
      description: "string",
      },
    },
  },
};
  1. Download the MDShield VSCode extension.

  2. Enjoy the type intelligence MDShield provided.

Configuration

strict

strict: true | false

  • strict mode:
    • Every markdown/mdx file's frontmatter need to set type field.
    • Can not have the undeclared field.
    • Can not have the undefined field that had been declared in the type config.
  • non-strict mode:
    • MDShield won't check markdown/mdx file without type field.
    • MDShield won't check the undeclared field.
    • MDShield won't check the undefined field.

meta

meta: frontmatter

We currently only support frontmatter in markdown and mdx file. We will support export object in the future.

export meta = {
  ...
}

types

types: {}

About the typeName

The types you want your frontmatter to have. The first layer is the name of this type.


// In mdshield.config.js
const config = {
  strict: true,
  meta: "frontmatter",
  types: {
    foo: { // <-- This type's name is foo 
      ...
    },
  },
};
// In your markdown file
---
type: foo // <-- You need to specific what is the target type of this markdown file
---

About the type

The type declaration is similar to Typescript, we support string, number, object, null and union type. But we don't support undefined type.

  • string | number | null = The field allows string, number or null/undefined.
  • string | 123 = The field allows string and number 123 specifically.
  • number | foo = The field allows number and string foo specifically.

Example

Let's say you have this config.

// mdshield.config.mjs

const config = {
  strict: true,
  meta: "frontmatter",
  types: {
    "hello": {
      title: "string",
      description: "string",
      date: "number | unspecific",
      author: "string"
    }
  }
}

export default config

And you have this markdown file.

---
type: hello <-- You need to specific typeName.
title: How are you <-- string, passed!
description: I am good <-- string, passed!
data: unspecific <-- string but unspecific is in the type, passed!
author: 234 <-- number, failed!
---

License

MIT

The logo of MDShield
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft