@prismicio/api-renderer
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -79,39 +79,35 @@ "use strict"; | ||
const direction = block.direction ? { direction: block.direction } : {}; | ||
const spans = block.content.spans | ||
? { | ||
spans: block.content.spans.map((m) => { | ||
const partial = { | ||
start: m.start, | ||
end: m.end, | ||
type: m.type, | ||
}; | ||
if (m.type === "hyperlink") { | ||
const asMaybeLink = Link_1.LinkContent.decode(m.data); | ||
const asLink = (() => { | ||
if (E.isRight(asMaybeLink)) { | ||
const content = { | ||
__TYPE__: Link_1.LinksTypes.LinkContent, | ||
value: Link_1.Link.encode(asMaybeLink.right.value), | ||
}; | ||
return renderStructuredTextLink(content, apiVersion, ctx); | ||
} | ||
return {}; | ||
})(); | ||
return { | ||
...partial, | ||
data: asLink, | ||
const spans = (block.content.spans || []).map((m) => { | ||
const partial = { | ||
start: m.start, | ||
end: m.end, | ||
type: m.type, | ||
}; | ||
if (m.type === "hyperlink") { | ||
const asMaybeLink = Link_1.LinkContent.decode(m.data); | ||
const asLink = (() => { | ||
if (E.isRight(asMaybeLink)) { | ||
const content = { | ||
__TYPE__: Link_1.LinksTypes.LinkContent, | ||
value: Link_1.Link.encode(asMaybeLink.right.value), | ||
}; | ||
return renderStructuredTextLink(content, apiVersion, ctx); | ||
} | ||
else if (m.type === "label") { | ||
return { | ||
...partial, | ||
data: { label: typeof m.data === "string" ? m.data : "" }, | ||
}; | ||
} | ||
else { | ||
return partial; | ||
} | ||
}), | ||
return {}; | ||
})(); | ||
return { | ||
...partial, | ||
data: asLink, | ||
}; | ||
} | ||
: {}; | ||
else if (m.type === "label") { | ||
return { | ||
...partial, | ||
data: { label: typeof m.data === "string" ? m.data : "" }, | ||
}; | ||
} | ||
else { | ||
return partial; | ||
} | ||
}); | ||
return { | ||
@@ -121,3 +117,3 @@ type: block.type, | ||
...label, | ||
...spans, | ||
spans, | ||
...direction, | ||
@@ -124,0 +120,0 @@ }; |
{ | ||
"name": "@prismicio/api-renderer", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Prismic renderers for the content API", | ||
@@ -38,3 +38,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@prismicio/types-internal": "0.2.7", | ||
"@prismicio/types-internal": "0.2.9", | ||
"tslib": "^2.3.1" | ||
@@ -41,0 +41,0 @@ }, |
@@ -101,38 +101,34 @@ import { | ||
const direction = block.direction ? { direction: block.direction } : {} | ||
const spans = block.content.spans | ||
? { | ||
spans: block.content.spans.map((m) => { | ||
const partial = { | ||
start: m.start, | ||
end: m.end, | ||
type: m.type, | ||
} | ||
if (m.type === "hyperlink") { | ||
const asMaybeLink = LinkContent.decode(m.data) | ||
const asLink = (() => { | ||
if (E.isRight(asMaybeLink)) { | ||
const content = { | ||
__TYPE__: LinksTypes.LinkContent, | ||
value: Link.encode(asMaybeLink.right.value), | ||
} as LinkContent | ||
return renderStructuredTextLink(content, apiVersion, ctx) | ||
} | ||
return {} | ||
})() | ||
const spans = (block.content.spans || []).map((m) => { | ||
const partial = { | ||
start: m.start, | ||
end: m.end, | ||
type: m.type, | ||
} | ||
if (m.type === "hyperlink") { | ||
const asMaybeLink = LinkContent.decode(m.data) | ||
const asLink = (() => { | ||
if (E.isRight(asMaybeLink)) { | ||
const content = { | ||
__TYPE__: LinksTypes.LinkContent, | ||
value: Link.encode(asMaybeLink.right.value), | ||
} as LinkContent | ||
return renderStructuredTextLink(content, apiVersion, ctx) | ||
} | ||
return {} | ||
})() | ||
return { | ||
...partial, | ||
data: asLink, | ||
} | ||
} else if (m.type === "label") { | ||
return { | ||
...partial, | ||
data: { label: typeof m.data === "string" ? m.data : "" }, | ||
} | ||
} else { | ||
return partial | ||
} | ||
}), | ||
} | ||
: {} | ||
return { | ||
...partial, | ||
data: asLink, | ||
} | ||
} else if (m.type === "label") { | ||
return { | ||
...partial, | ||
data: { label: typeof m.data === "string" ? m.data : "" }, | ||
} | ||
} else { | ||
return partial | ||
} | ||
}) | ||
return { | ||
@@ -142,3 +138,3 @@ type: block.type, | ||
...label, | ||
...spans, | ||
spans, | ||
...direction, | ||
@@ -145,0 +141,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
734772
23015
94
9
16
2
51
+ Added@prismicio/types-internal@0.2.9(transitive)
- Removed@prismicio/types-internal@0.2.7(transitive)