VuePress Plugin Auto Meta
Auto meta tags plugin for VuePress 1.x
What
This is a Plug-and-Forget VuePress plugin that will auto generate the meta tags
for VuePress pages or posts.
Install
$ npm install -D vuepress-plugin-autometa
$ yarn add -D vuepress-plugin-autometa
Usage
Add vuepress-plugin-autometa
in your site or theme config file.
See official docs on using a plugin
const autometa_options = {
site: {
name : 'Webmasterish',
twitter: 'webmasterish',
},
canonical_base: 'https://webmasterish.com',
};
module.exports = {
plugins: [
[ 'autometa', autometa_options ]
]
}
Options
See Plugin Option API official docs
Default options
You can override default options in 2 ways:
- Global plugin options set in
.vuepress/config.js
or .vuepress/theme/index.js
as described in Usage - Individual page/post
frontmatter
as shown in Examples
const default_options = {
enable : true,
image : true,
twitter: true,
og : true,
schema : true,
canonical_base: '',
author: {
name : '',
twitter: '',
},
site: {
name : '',
twitter: '',
},
description_sources: [
'frontmatter',
'excerpt',
/^((?:(?!^#)(?!^\-|\+)(?!^[0-9]+\.)(?!^!\[.*?\]\((.*?)\))(?!^\[\[.*?\]\])(?!^\{\{.*?\}\})[^\n]|\n(?! *\n))+)(?:\n *)+\n/img,
/<p(?:.*?)>(.*?)<\/p>/i,
],
image_sources: [
'frontmatter',
/!\[.*?\]\((.*?)\)/i,
/<img.*?src=['"](.*?)['"]/i,
],
};
Examples
Assuming we have this sample index.md
file
---
title: Plans for the Next Iteration of VuePress
date: 2018-12-28T15:18:13+0200
autometa:
author:
name: Evan You
twitter: youyuxi
tags:
- VuePress
- auto meta tags
- are cool
---
# {{ $page.title }}
## Simplicity First
Minimal setup with markdown-centered project structure
helps you focus on writing.
![random image](http://lorempixel.com/640/480)
## Vue-Powered
Enjoy the dev experience of Vue + webpack, use Vue components in markdown,
and develop custom themes with Vue.
## Performant
VuePress generates pre-rendered static HTML for each page,
and runs as an SPA once a page is loaded.
The auto generated metas will be as follows:
<meta name="description" content="Minimal setup with markdown-centered project structure helps you focus on writing.">
<meta name="image" content="http://lorempixel.com/640/480">
<meta name="twitter:title" content="Plans for the Next Iteration of VuePress">
<meta name="twitter:description" content="Minimal setup with markdown-centered project structure helps you focus on writing.">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="http://lorempixel.com/640/480">
<meta name="twitter:url" content="https://webmasterish.com/plans-for-the-next-iteration-of-vuepress/">
<meta name="twitter:creator" content="@youyuxi">
<meta name="twitter:site" content="@webmasterish">
<meta property="og:type" content="article">
<meta property="og:title" content="Plans for the Next Iteration of VuePress">
<meta property="og:description" content="Minimal setup with markdown-centered project structure helps you focus on writing.">
<meta property="og:image" content="http://lorempixel.com/640/480">
<meta property="og:url" content="https://webmasterish.com/plans-for-the-next-iteration-of-vuepress/">
<meta property="og:site_name" content="Webmasterish">
<meta property="article:author" content="Evan You">
<meta property="article:published_time" content="2018-12-28T15:18:13+0200">
<meta property="article:tag" content="VuePress">
<meta property="article:tag" content="auto meta tags">
<meta property="article:tag" content="are cool">
<meta itemprop="name" content="Plans for the Next Iteration of VuePress">
<meta itemprop="description" content="Minimal setup with markdown-centered project structure helps you focus on writing.">
<meta itemprop="image" content="http://lorempixel.com/640/480">
Reference
License
MIT © webmasterish