1.6.3 • Published 3 years ago

nuxt-page-generator-helper v1.6.3

Weekly downloads
39
License
MIT
Repository
github
Last release
3 years ago

nuxt-page-generator-helper

Grabarz & Partner - Module

Master

npm version npm downloads Renovate - Status License

A helper for the generated static pages and target oriented integration of components.

Generate your static pages without using payload-extractor. Integrate your components on the page with targeted embedding and to enable the best chunk splitting.

Every not loaded resource is a good resource 🎉

📖 Release Notes

Setup

⚠️ Important: nuxt-i18n and @nuxtjs/sitemap must not be included separately.
nuxt-page-generator-helper automatically includes the modules and offers full configurability via the module options.

nuxt-i18n is a core component, if not used limit it to a default language.

  1. Add nuxt-page-generator-helper entry to gitignore.

  2. Add nuxt-page-generator-helper dependency to your project

yarn add nuxt-page-generator-helper # or npm install nuxt-page-generator-helper
  1. Add nuxt-page-generator-helper to the modules section of nuxt.config.js
{
  modules: [

    ['nuxt-page-generator-helper', {
      debug: true,
      dynamicContent: false,
      adapter: require('./adapter/local-json'),
      adapterOptions: {},
      componentPath: '@/components/organisms',
      pageExtend: '@/extends/PageBuild',
      layoutCache: false,
      routesCache: false,
      ignoreRoutes: [
        'index',
        'page',
        'nested-page'
      ],
      nuxtI18n: {
        locales: [
          {
            code: 'en',
            iso: 'en'
          },
          {
            code: 'de',
            iso: 'de'
          }
        ],
        parsePages: true,
        defaultLocale: 'en',
        strategy: 'prefix_except_default',
        seo: false,
        vueI18nLoader: false,
        vueI18n: {
          fallbackLocale: 'en',
          messages: {
            en: require('./globals/locales/en.json'),
            de: require('./globals/locales/de.json')
          }
        }
      },
      sitemap: {
        path: 'sitemap.xml',
        hostname: 'http://localhost',
        cacheTime: 1000 * 60 * 15,
        gzip: false,
        exclude: [],
        routes: [],
        defaults: {
          changefreq: 'daily',
          priority: 1,
          lastmod: new Date(),
          lastmodrealtime: true
        }
      }
    }]

  ]
}

Options

PropertyTypeDescriptionDefault ValueRequired
debugBooleanDebug-Modefalsefalse
dynamicContentBooleanIf set, the content is reloaded dynamically, no pages are generated.development => trueproduction => falsefalse
adapterObject, StringFile path or import with functions for querying the page structure with content.nulltrue
adapterOptionsObjectAdapter to retrieve the payloads. Contains the calls getRoute, getRoutes, getLayout and path specification (PATH).nulltrue
pageExtendObjectPath to the page extension that is used during generation.nuxt-page-generator-helper/PageExtend.vuefalse
componentPathStringComponent src Path. Is required for embedding specified components in a page.@/componentsfalse
componentPrefixStringPrefix for component imports in generated pages.Example: Component Text -> Component PrefixTextprefixfalse
asyncComponentLoadBooleanWhen set, components of a page are loaded asynchronously.truefalse
lazyHydrateEnableBooleanComponents that can be reloaded can be controlled with LazyHydration.Example:With the setting maxEagerComponents: 1, the first component is initialized at whenIdle. All others at whenVisible.vue-lazy-hydrationtruefalse
lazyHydrateRootMarginStringSpecifies when the whenVisible event is triggered.Example:Component initialization occurs,Component is less than 80px away from the visible area.80pxfalse
lazyHydrateMaxIdleNumberSpecifies the number of components that are initialized by LazyHydrate whenIdle.Important: Only active if asyncComponentLoad is set.1false
layoutCacheBooleanIf active, the adapter result is stored locally for layout.falsefalse
routesCacheBooleanIf active, the adapter result is stored local for routes.falsefalse
ignoreRoutesArrayList of route names, to be ignore by routes extend.Example: ['index', 'page', 'nested-page']nulltrue
cleanRoutesBooleanIf set, all already registered routes will be removed from the list.falsefalse
nuxtI18nObjectConfiguration for nuxt-i18ntrue
sitemapObjectConfiguration for @nuxtjs/sitemapfalse

Build matrix of the page components generation

CommandGenerate Vue-PagesisDevgeneratebuild
nuxtfalsetruefalsetrue
nuxt buildtruefalsefalsetrue
nuxt startfalsefalsefalsefalse
nuxt generatetruefalsetruetrue

Adapters

📖 Adapter Docs

Adapter local-json

Adapter local-json is used to work with local JSON files.

📖 Sources

Plugins

👁 All plugins available in context client and server.

async $getGeneratorRouteData

Retrieves the data for the current route using the adapter method getRoute.

Recommendation is to use Page asyncData for the request.

Page usage example

export default {
  asyncData ({ $getGeneratorRouteData }) {
    return $getGeneratorRouteData()
  }
}

async $getGeneratorLayoutData

Retrieves the data for the layout using the adapter method getLayout.

Recommendation is to use Store nuxtInitServer for the request. For development, the call can also be placed in the dev extension of the page in the fetch method.

Store usage example

nuxtServerInit

export const actions = {
  async nuxtServerInit ({ dispatch }, { $getGeneratorLayoutData }) {
    dispatch('layout/setData', await $getGeneratorLayoutData())
  }
}

fetch

export default {
  async fetch ({ store, $getGeneratorLayoutData }) {
    store.dispatch('layout/setData', await $getGeneratorLayoutData())
  }
}

$getGeneratorOptions

Gets the adapter settings.

Plugin usage example

export default (ctx) => {
  ctx.$getGeneratorLayoutData = () => {
    return getLayout(ctx.$getGeneratorOptions());
  }
}

Usage

Coming Soon...

But you can have a look at the module example. Example Directory

Preview

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Build and start with express npm run start:generate
  4. Open http://127.0.0.1:3000 in Browser.

or look here

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using npm run dev

License

MIT License

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

4 years ago

1.5.4

4 years ago

1.6.0

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago