@metascraper/helpers 5.28.9 → 5.29.0

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/index.js +10 -5
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -8,11 +8,11 @@ const {
8
8
  includes,
9
9
  invoke,
10
10
  isArray,
11
+ isBoolean,
12
+ isDate,
11
13
  isEmpty,
12
14
  isNumber,
13
- isBoolean,
14
15
  isString,
15
- isDate,
16
16
  lte,
17
17
  replace,
18
18
  size,
@@ -299,13 +299,18 @@ memoizeOne.EqualityUrlAndHtmlDom = (newArgs, oldArgs) =>
299
299
  const jsonld = memoizeOne(
300
300
  $ =>
301
301
  $('script[type="application/ld+json"]')
302
- .map((i, e) => {
302
+ .map(function () {
303
303
  try {
304
- return JSON.parse(
305
- $(e)
304
+ const el = $(this)
305
+ const json = JSON.parse(
306
+ $(el)
306
307
  .contents()
307
308
  .text()
308
309
  )
310
+
311
+ const { '@graph': graph, ...props } = json
312
+ if (!graph) return json
313
+ return graph.map(item => ({ ...props, ...item }))
309
314
  } catch (_) {
310
315
  return undefined
311
316
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@metascraper/helpers",
3
3
  "description": "Collection of helper functions used by metascraper",
4
4
  "homepage": "https://nicedoc.io/microlinkhq/metascraper/packages/metascraper-helpers",
5
- "version": "5.28.9",
5
+ "version": "5.29.0",
6
6
  "main": "index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "2062907198cd0fa209e844107a0b1207e7516880"
66
+ "gitHead": "86572d38b9d5de0af1608d1516756cc3ed5a43af"
67
67
  }