@ekino/rendr-core
Advanced tools
Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6
@@ -601,3 +601,5 @@ var __extends = (this && this.__extends) || (function () { | ||
var page = new types_1.Page(); | ||
pages.forEach(function (p) { | ||
pages | ||
.filter(function (p) { return p; }) | ||
.forEach(function (p) { | ||
page.cache.ttl = p.cache.ttl; | ||
@@ -604,0 +606,0 @@ page.cache.sharedTtl = p.cache.sharedTtl; |
@@ -154,3 +154,5 @@ var __assign = (this && this.__assign) || function () { | ||
var page = new Page(); | ||
pages.forEach(function (p) { | ||
pages | ||
.filter(function (p) { return p; }) | ||
.forEach(function (p) { | ||
page.cache.ttl = p.cache.ttl; | ||
@@ -157,0 +159,0 @@ page.cache.sharedTtl = p.cache.sharedTtl; |
@@ -180,3 +180,5 @@ "use strict"; | ||
var page = new types_1.Page(); | ||
pages.forEach(function (p) { | ||
pages | ||
.filter(function (p) { return p; }) | ||
.forEach(function (p) { | ||
page.cache.ttl = p.cache.ttl; | ||
@@ -183,0 +185,0 @@ page.cache.sharedTtl = p.cache.sharedTtl; |
{ | ||
"name": "@ekino/rendr-core", | ||
"license": "MIT", | ||
"version": "1.0.0-alpha.5", | ||
"version": "1.0.0-alpha.6", | ||
"main": "dist/lib/index.js", | ||
@@ -22,3 +22,3 @@ "typing": "dist/lib/index.d.ts", | ||
}, | ||
"gitHead": "57a05c575a0e0e712c859607a879f1d6b5a77255" | ||
"gitHead": "1cf73df8fb3a273a3773353a78e6827ea8e238fa" | ||
} |
@@ -117,2 +117,38 @@ import { createPage, mergePages, Page, createContext } from "./index"; | ||
}); | ||
it("should not generate an error if on entry is not defined", () => { | ||
const page = new Page(); | ||
page.id = "the child page"; | ||
page.head.defaultTitle = ""; | ||
page.head.htmlAttributes = { | ||
foo: "bar", | ||
}; | ||
page.head.meta = [{ property: "value" }]; | ||
page.cache.ttl = 100; | ||
page.path = "/the-child"; | ||
page.statusCode = 403; | ||
page.template = "2-columns"; | ||
page.blocks = [ | ||
{ | ||
id: "id-1", | ||
meta: {}, | ||
container: "header", | ||
order: 1, | ||
settings: {}, | ||
type: "type-child-1", | ||
}, | ||
{ | ||
id: "id-2", | ||
meta: {}, | ||
container: "header", | ||
order: 1, | ||
settings: {}, | ||
type: "type-child-2", | ||
}, | ||
]; | ||
const p = mergePages([undefined, null, page]); | ||
expect(p).toMatchSnapshot(); | ||
}); | ||
}); | ||
@@ -119,0 +155,0 @@ |
@@ -201,33 +201,35 @@ import parse from "url-parse"; | ||
pages.forEach((p) => { | ||
page.cache.ttl = p.cache.ttl; | ||
page.cache.sharedTtl = p.cache.sharedTtl; | ||
page.head = { | ||
titleTemplate: | ||
p.head.titleTemplate.length > 0 | ||
? p.head.titleTemplate | ||
: page.head.titleTemplate, | ||
defaultTitle: | ||
p.head.defaultTitle.length > 0 | ||
? p.head.defaultTitle | ||
: page.head.defaultTitle, | ||
title: p.head.title.length > 0 ? p.head.title : page.head.title, | ||
links: [...page.head.links, ...p.head.links], | ||
htmlAttributes: | ||
Object.keys(p.head.htmlAttributes).length > 0 | ||
? p.head.htmlAttributes | ||
: page.head.htmlAttributes, | ||
// for meta, we append from parent | ||
meta: [...page.head.meta, ...p.head.meta], | ||
}; | ||
page.path = p.path; | ||
page.template = p.template.length > 0 ? p.template : page.template; | ||
page.type = p.type.length > 0 ? p.type : page.type; | ||
page.id = p.id; // we always need to return the last id | ||
page.statusCode = p.statusCode; | ||
page.settings = { ...page.settings, ...p.settings }; | ||
page.blocks = [...page.blocks, ...p.blocks]; | ||
}); | ||
pages | ||
.filter((p) => p) // make sure page is defined | ||
.forEach((p) => { | ||
page.cache.ttl = p.cache.ttl; | ||
page.cache.sharedTtl = p.cache.sharedTtl; | ||
page.head = { | ||
titleTemplate: | ||
p.head.titleTemplate.length > 0 | ||
? p.head.titleTemplate | ||
: page.head.titleTemplate, | ||
defaultTitle: | ||
p.head.defaultTitle.length > 0 | ||
? p.head.defaultTitle | ||
: page.head.defaultTitle, | ||
title: p.head.title.length > 0 ? p.head.title : page.head.title, | ||
links: [...page.head.links, ...p.head.links], | ||
htmlAttributes: | ||
Object.keys(p.head.htmlAttributes).length > 0 | ||
? p.head.htmlAttributes | ||
: page.head.htmlAttributes, | ||
// for meta, we append from parent | ||
meta: [...page.head.meta, ...p.head.meta], | ||
}; | ||
page.path = p.path; | ||
page.template = p.template.length > 0 ? p.template : page.template; | ||
page.type = p.type.length > 0 ? p.type : page.type; | ||
page.id = p.id; // we always need to return the last id | ||
page.statusCode = p.statusCode; | ||
page.settings = { ...page.settings, ...p.settings }; | ||
page.blocks = [...page.blocks, ...p.blocks]; | ||
}); | ||
return page; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
152860
3072