1.16.0 • Published 5 months ago

@bkwld/cloak v1.16.0

Weekly downloads
29
License
MIT
Repository
-
Last release
5 months ago

Cloak

Opinionated Nuxt boilerplate with support for Craft and Contentful.

npm.io

Install

The recommended way to use Cloak is to install it with yarn create cloak-app. This command use create-cloak-app and will scaffold a new Nuxt app that uses Cloak.

Usage

From your project's nuxt.config.coffee:

# Make boilerplate, setting some options
{ mergeConfig, makeBoilerplate } = require '@bkwld/cloak'
boilerplate = makeBoilerplate
  siteName: 'My Site'
  cms: 'craft'
  pageTypes: ['towers_towers_Entry']

# Merge project specific config with cloak boilerplate
module.exports = mergeConfig boilerplate,

  # Append additional internal routes for vue-routing-anchor-parser
  anchorParser: internalUrls: [
    /^https?:\/\/(www)?\.domain\.com/
  ]

  # Customize routes
  router: extendRoutes: (routes, resolve) ->

    # Make all path params required in detail routes
    detailRoutes = ['blog-tag-tag', 'blog-category-article']
    routes.filter ({ name }) -> name in detailRoutes
    .forEach (route) -> route.path = route.path.replace /\?/g, ''

    # Append routes from boilerplate
    return boilerplate.router.extendRoutes routes, resolve

Options

These are options you can pass to makeBoilerplate. See the source code for defaults.

General

PropertyDescription
siteNameName of site gets prepended to the <title> and used in PWA manifest.
polyfillsArray of polyfill.io keywords, for example URL.

CMS

PropertyDescription
cmsMay be empty, craft, or contentful.
pageTypes (if Craft)An array of Craft _typename values.
pageTypes (if Contentful)An array of objects with the following properties: contentType (a Contentful contentType string), routeField (the field that holds the value you'll use in your route, defaults to "slug"), and route (a function that is passed the value from the routeField and which should return a route path).
generateOnlyRoutesCraft only. Typically we generate a gql query per pageType that fetches the data for all entries, passing their data into the page components as the payload. Set this to true to disable this. You would do this on sites with many entries because this query becomes very expensive for Craft to execute.

Visual

PropertyDescription
imgixUrlFor example, https://project.imgix.net.
srcsetWidthsArray of integer widths that are used to make the Visual srcSet.
placeholderColorThe default placeholder color for Visual.

Other Config

Contentful

The following ENV variables are expected to use Contentful

PropertyDescription
CONTENTFUL_SPACEThe space id.
CONTENTFUL_ACCESS_TOKENThe Delivery API access token.
CONTENTFUL_PREVIEW_ACCESS_TOKENThe Preview API access token.
CONTENTFUL_PREVIEWSet to true use the Preview API rather than the Delivery API. Aka, to return draft/changed entries.

Sentry

To enable Sentry logging, you'll need to set the following ENV variables:

PropertyDescription
SENTRY_DSNThis will be provided when you create a new project in Sentry.
SENTRY_AUTH_TOKENGet this from your user API settings. You need the org:read and project:releases permissions for the token (per authToken docs from sentry-webpack-plugin).

You also need to create a .sentryclirc as described here. create-cloak-app will have already created this. Example:

[defaults]
org=bukwild
project=my-project

Libraries

Besides providing a bunch of nuxt.config boilerplate, this project also provides these shared resources:

  • components - Vue components that are already setup for autodiscovery with no prefixing.
  • fragments - GraphQL fragments for common objects
  • mixins - Vue mixins
  • services - Libraries of methods that can be imported into your code and which are also injected globally. For example, @$craft and @$defer are available in all components.

Notes

  • Using cjs module syntax for to make developing via yarn link simpler. I tried using esm package but it ran into issues with imports of imports.
  • Using a fork of webpack-graphql-loader to work around issues with the loader not being found from the root package. I think because it referenced some old and unecessary deps.
  • Use the Page View dataLayer event for firing Page View style tags from GTM
1.16.0

5 months ago

1.15.8

2 years ago

1.15.7

2 years ago

1.15.6

2 years ago

1.15.5

2 years ago

1.15.4

2 years ago

1.15.0

2 years ago

1.15.3

2 years ago

1.15.2

2 years ago

1.15.1

2 years ago

1.14.1

2 years ago

1.14.0

2 years ago

1.13.0

2 years ago

1.12.1

2 years ago

1.12.0

2 years ago

1.11.0

2 years ago

1.10.1

2 years ago

1.10.0

2 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.8.0

3 years ago

1.9.2

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.2.0

3 years ago

1.3.0

3 years ago

1.1.0

3 years ago

0.3.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago