@symbo.ls/utils 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/navigation.js +9 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "src/index.js",
package/src/navigation.js CHANGED
@@ -1,17 +1,15 @@
1
1
  'use strict'
2
2
 
3
- import { SITEMAP } from '../data'
4
-
5
- export const filterHrefs = () => {
6
- return Object.values(SITEMAP)
3
+ export const filterHrefs = (sitemap) => {
4
+ return Object.values(sitemap)
7
5
  .map(({ href, sub_links }) => // eslint-disable-line
8
6
  [href, sub_links.map(({ href }) => href).filter(v => v.indexOf('#') === -1)].filter(v => v.length > 0)
9
7
  )
10
8
  }
11
9
 
12
- export const findCurrentIndex = () => { // eslint-disable-line
10
+ export const findCurrentIndex = (sitemap) => { // eslint-disable-line
13
11
  const { pathname } = window.location
14
- const hrefArray = filterHrefs()
12
+ const hrefArray = filterHrefs(sitemap)
15
13
  let index
16
14
 
17
15
  hrefArray.map((v, k) => {
@@ -26,17 +24,17 @@ export const findCurrentIndex = () => { // eslint-disable-line
26
24
  }
27
25
 
28
26
  /** Parses sitemap and detects current, active, and previous pages from current url path */
29
- export const setPaginationNames = () => {
27
+ export const setPaginationNames = (sitemap) => {
30
28
  const { pathname } = window.location
31
- const hrefArray = filterHrefs()
29
+ const hrefArray = filterHrefs(sitemap)
32
30
  const state = {}
33
31
 
34
32
  hrefArray.map((v, k) => {
35
33
  const categoryRoute = v[0]
36
34
  const subcategoryRoutes = v[1]
37
- const previousCat = SITEMAP[k - 1]
38
- const activeCat = SITEMAP[k]
39
- const nextCat = SITEMAP[k + 1]
35
+ const previousCat = sitemap[k - 1]
36
+ const activeCat = sitemap[k]
37
+ const nextCat = sitemap[k + 1]
40
38
 
41
39
  const isRootCategory = categoryRoute === pathname
42
40
  const isSubcategory = subcategoryRoutes && subcategoryRoutes.indexOf(pathname) > -1