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-auto-layout
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Astro M²DX - Remark plugin for auto-layout

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 support per-directory default layouts for Astro markdown-pages. This plugin is deprecated, please use the plugin remark-astro-frontmatter instead.

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 to add support for automatic layout insertion to markdown-pages in the context of Astro site generation.

In Astro you usually define the layout for markdown pages (.md and .mdx) with the frontmatter property layout, which inserts the generated HTML content into that layout's default slot. With this plugin you can define this per directory.

When should I use this?

If you want to use the same layout for all markdown-pages within a directory and its subdirectories and want to 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-auto-layout

Use

In your astro.config.mjs

import { defineConfig } from 'astro/config';

import mdx from '@astrojs/mdx';
import autoLayout from '@astro-m2dx/remark-astro-auto-layout';
// ^^^

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

This uses the default options, where the name of the default Astro layout file is _layout.astro.

Note the _ in front of the name, it allows to add astro files to your pages directory, that are not considered pages.

Now create a standard Astro layout file with that name in the directory with your markdown pages; it will be used for all markdown files that do not specify a layout property in their frontmatter.

Options

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

    remarkPlugins: [[autoLayout, {name: "_blog-design.astro"}]],

Note again the _ at the start of the filename... Because the file must reside in the pages directory, but we do not want it to be generated as page, we must use a name starting with underscore.

Package Sidebar

Install

npm i @astro-m2dx/remark-astro-auto-layout

Weekly Downloads

0

Version

0.0.6

License

MIT

Unpacked Size

7.28 kB

Total Files

6

Last publish

Collaborators

  • shackhacker-christian