Have ideas to improve npm?Join in the discussion! »

@netsells/nuxtjs-page-store

1.0.0 • Public • Published

NuxtJS Page Store

A page data store which clears itself down between pages using nuxt middleware. Useful for passing data from the page to the layout.

Installation

yarn add @netsells/nuxtjs-page-store

Usage

This module is built on top of Vuex for reactivity.

Add to your nuxt config:

    modules: [
        '@netsells/nuxtjs-page-store',
    ],

set

Set the data object, is merged with existing data

this.$store.commit('pageStore/set', {
    title: 'Homepage',
    subtitle: 'Foo bar',
})

clear

Clear all the page data. Is called internally between pages

this.$store.commit('pageStore/clear');

getters

 
import { mapGetters } from 'vuex';
 
export default {
    name: 'my-layout',
 
    computed: {
        ...mapGetters('pageStore', ['get']),
    },
};

And in your template:

<div>
    <h1>{{ get('title') }}</h1>
    <h2>{{ get('subtitle') }}</h2>
    <nuxt />
</div>

Keywords

none

Install

npm i @netsells/nuxtjs-page-store

DownloadsWeekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

303 kB

Total Files

6

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar