Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ecomplus/storefront-router

ecomplus834MIT2.2.1

Universal JS router for E-Com Plus storefront

ecomplus, storefront, router, ecommerce, universal-app

readme

E-Com Plus Storefront Router

Publish CodeFactor npm version License MIT

SPA/SSR router for E-Com Plus storefront

CHANGELOG

Usage

The @ecomplus/storefront-router package may be used for:

  • List all products, brands, categories and collections pages (URL paths) for prerenderization/SSR;
  • Based on URL path, get document body (product, brand, category, collection) on browser or server side to render the page markup;

It's available for both Node.js and browser environments.

Example

const router = new EcomRouter()
// Simple example resolving all routes
router.list()
  .then(routes => {
    routes.forEach(route => {
      console.log(route.resource)
      router.resolve(route)
        .then(context => {
          console.log(context.body)
        })
        .catch(error => { throw error })
    })
  })
  .catch(error => {
    console.error(error)
    if (error.response) {
      console.log(error.response)
    }
  })

Installation

It may require and doesn't include core-js (optional) and @ecomplus/utils (peer dependency).

Webpack

npm i --save core-js @ecomplus/utils @ecomplus/storefront-router

Node.js

npm i --save @ecomplus/utils @ecomplus/storefront-router

CDN

<script src="https://cdn.jsdelivr.net/npm/@ecomplus/storefront-router/dist/ecom-router.var.min.js"></script>

When importing from CDN, ecomUtils and ecomClient libraries must be included separately and available on window scope.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.2.1 (2020-10-07)

Bug Fixes

  • pkg: fix pkg node entry (main) (57dac7e)

2.2.0 (2020-04-30)

Features

  • list: add sku field to products (d1379dc)

2.1.0 (2020-04-08)

Features

  • list: add 'name' field to route object (when available) (f7484c8)

2.0.1 (2020-01-02)

2.0.0 (2020-01-02)

⚠ BREAKING CHANGES

  • deps: ecomplus/utils and core-js no more direct dependencies

  • deps: fix dependencies (peer) (458e903)

1.0.1 (2019-08-24)

Bug Fixes

  • constructor: fix gettings store id from config dynamically (098dd63)

1.0.0 (2019-08-12)

0.4.3 (2019-08-06)

0.4.2 (2019-07-29)

Bug Fixes

  • constructor: setup this.location with location interface (170612c)

0.4.1 (2019-07-29)

Tests

  • fix: update script src and constructor on html test file (d0b32c5)

0.4.0 (2019-07-29)

Build System

  • webpack: edit output filename (c348db4)
  • webpack: fix webpack config for browser output and global var (1278b95)

BREAKING CHANGES

  • webpack: changed global variable (EcomRouter)

0.3.2 (2019-07-26)

0.3.1 (2019-07-26)

Build System

  • webpack: extend webpack for outputs with and without polyfill (a1726ef)

Tests

  • fix: fix test html file importing correct js script (5799c58)

0.3.0 (2019-07-26)

Build System

  • webpack: fixing webpack output config, exporting the constructor (9ddace8)

Tests

  • fix: using global Router constructor (055211c)

BREAKING CHANGES

  • webpack: changed lib returned output

0.2.5 (2019-07-26)

0.2.4 (2019-07-26)

Bug Fixes

  • list: check it this path is not already in use (60c1a13)

0.2.3 (2019-07-26)

Bug Fixes

  • list: checking from slug prop on data (1486763)
  • list: handling list responses correcly (result array) (4f2483f)

0.2.2 (2019-07-26)

0.2.1 (2019-07-26)

0.2.0 (2019-07-25)

Bug Fixes

  • resolve: checking resource and _id from route obejct (2a2c170)

Features

  • method: handling 'list' method (a29fb08)

0.1.1 (2019-07-25)

0.1.0 (2019-07-25)

Bug Fixes

  • constructor: add resolve function, fix handling map page object (27bf1d4)
  • constructor: remove context, add list (7903b2a)
  • constructor: this.context instead of this.content (08a2223)
  • router: making it a constructor, setup context object (6f6fb63)

Build System

  • externals: not using 'universal-router' pkg (845496d)
  • webpack: exclude externals on production build only (ef09401)

Features

  • constructor: map function to return resource and id from slug (96de409)
  • current-object: get current page object from store api first (511f76d)
  • method: handling 'map' method (181f9e2)
  • method: handling 'resolve' method (02b96d6)
  • method: handling 'setupStore' method (0eed873)

refactor

  • constructor: refactoring Route class, edit params and members (1b6d8fb)

Tests

  • router: setup constructor and instance from global '' (389b132)

BREAKING CHANGES

  • constructor: constructor param changed

0.0.2 (2019-07-22)

Build System

  • babel: setup babel config (c32f76f)
  • webpack: ignore external packages (dependencies) (539fcd1)
  • webpack: setup base webpack config (759487d)