Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ulu/unplugin-vue-router-frontmatter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ulu/unplugin-vue-router-frontmatter

Pull frontmatter from pages that are markdown and add to route.meta. Use in extendRoute() method of unplugin-vue-router.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

@ulu/unplugin-vue-router-frontmatter

Pull frontmatter from pages that are markdown and add to route.meta. Use in extendRoute() method of unplugin-vue-router.

Example Usage in


import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueRouter from "unplugin-vue-router/vite";
import markdown from 'unplugin-vue-markdown/vite';
import addFrontmatter from "@ulu/unplugin-vue-router-frontmatter";

export default defineConfig({
  plugins: [
    markdown(),
    vueRouter({
      extensions: [".vue", ".md"],
      extendRoute(route) {
        addFrontmatter(route);
      }
    }),
    vue({
      include: [/\.vue$/, /\.md$/]
    }),
  ],
});

You can also optionally pass a callback to modify the frontmatter that's added


import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueRouter from "unplugin-vue-router/vite";
import markdown from 'unplugin-vue-markdown/vite';
import addFrontmatter from "@ulu/unplugin-vue-router-frontmatter";

export default defineConfig({
  plugins: [
    markdown(),
    vueRouter({
      extensions: [".vue", ".md"],
      extendRoute(route) {
        addFrontmatter(route, ({ 
          title, 
          category, 
          order 
        }) => {
          return { title, category, order };
        });
      }
    }),
    vue({
      include: [/\.vue$/, /\.md$/]
    }),
  ],
});

Original Use Case

Used with vite-ssg, unplugin-vue-markdown (frontmatter) and adding it to unplugin-vue-router (route.meta) so that things like menus can be built dynamically (toolkits, guides, etc). And to avoid having to do any of this on the client side. For example grabbing each pages (title, order/weight) and adding it to the route meta in order to base menus on route structure.

Keywords

FAQs

Package last updated on 18 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc