This Vue2 plugin allows you to automatically generate a table of contents and insert it into your webpage.
# Npm
npm install @rovahub/vue-easy-toc --save
# Yarn
yarn add @rovahub/vue-easy-toc
Import the @rovahub/vue-easy-toc in your main JavaScript file in src/ folder.
# src/main.js
// main.js
import Vue from "vue";
import App from "./App.vue";
import VueEasyTocPlugin from "@rovahub/vue-easy-toc";
Vue.config.productionTip = false;
Vue.use(VueEasyTocPlugin);
new Vue({
render: h => h(App)
}).$mount("#app");
Create JS file in /plugins/ folder and add content to the plugin file.
# plugins/vue-easy-toc.js
import Vue from 'vue';
import VueEasyTocPlugin from "@rovahub/vue-easy-toc";
Vue.use(VueEasyTocPlugin);
In your nuxt.config.js file, add the plugin to the plugins array:
# nuxt.config.js
module.exports = {
// ...
plugins: [
{ src: "~/plugins/vue-easy-toc.js", mode: "client" }
],
// ...
}