JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27202
  • Score
    100M100P100Q138412F
  • License WTFPL

markdown file with metadata to vue component loader.

Package Exports

  • vue-content-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-content-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

vue-content-loader

Extends vue-markdown-loader to accept front-matter and adds the metadata to Vue component.

Installation

npm install vue-content-loader --save-dev

Basic Usage

The following markdown file:

// ~content/MyFirstPost.md
---
title: "My First Post"
---

# Hello World

Can be used as such:

import FirstPost from '~content/FirstPost'

FirstPost.$metadata // { title: "My First Post" }

Note: vue-content-loader also supports Nuxt.js layout property. It treats this key in the front-matter differently, inserting it into the component's layout property, rather than the $metadata property.

How it works

You can use front-matter and Vue components in your markdown files:

---
title: "My first post!"
---

# Hello

This is my newest project:

<SomeDemo />

<script>
import SomeDemo from '~components/demo'

export default {
  component: {
    SomeDemo
  }
}
</script>

The content is parsed in three main steps:

First, the metadata is extracted and the front matter is commented out.

Then, the markdown file is converted into a single Vue component file.

Finally, the $metadata property is added to Vue component.

The result:

// ~content/FirstPost.md

<template>
<!--
title: "My first post!"
-->
<h1>Hello</h1>
<SomeDemo></SomeDemo>
</template>

<script>
import SomeDemo from '~components/demo'
export default {
  component: {
    SomeDemo
  },
  $metadata: { title: "My first post!" }
}
</script>

More information

See vue-markdown-loader for additional usage.

Lisence

WTFPL