This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@astro-m2dx/remark-astro-frontmatter
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Astro M²DX - Remark plugin for common frontmatter

DEPRECATED: Please consider using the plugin astro-m2dx, which bundles all features from the different @astro-m2dx plugins in one plugin (all features are opt-in).

remark plugin to define common frontmatter for all Markdown files in a directory, e.g. to set a common layout for all files.

Astro M²DX is a set of plugins allowing you to define an Astro 🚀 publishing pipeline for Markdown/MDX documents with full MDX features, but without the technical fuss, i.e. you and your non-tech editors can write clean markdown.

Have a look at the other astro-m2dx plugins.

Content

What is this?

This package is a remark plugin for markdown files in the context of Astro site generation, that allows you to define common frontmatter for all markdown files in a directory and it's subdirectories.

When should I use this?

If you want to extract common frontmatter properties for all files in a directory, e.g. the layout to a common file within the directory (_frontmatter.yaml by default). This helps you, keep your markdown files and their frontmatter as clean as possible.

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:

npm install -D @astro-m2dx/remark-astro-frontmatter

Use

In your astro.config.mjs

import { defineConfig } from 'astro/config';

import mdx from '@astrojs/mdx';
import frontmatter from '@astro-m2dx/remark-astro-frontmatter';
// ^^^

// https://astro.build/config
export default defineConfig({
  integrations: [mdx()],
  markdown: {
    remarkPlugins: [frontmatter],
    //              ^^^
    extendDefaultPlugins: true,
  },
});

This uses the default options, where the name of the frontmatter files is _frontmatter.yaml.

Now you can create frontmatter files in your src directory to define common properties. The properties will be deeply merged, where properties from markdown file's frontmatter will have highest priority, and properties from frontmatter files closer to the markdown file will take precedence over properties from files higher up the tree.

Options

If you want to use a different name for the frontmatter files, you can specify it in the plugin's name option like so:

    remarkPlugins: [[frontmatter, {name: "_props.yaml"}]],

Package Sidebar

Install

npm i @astro-m2dx/remark-astro-frontmatter

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

7.51 kB

Total Files

6

Last publish

Collaborators

  • shackhacker-christian