Skip to content

Commit

Permalink
fixed #618
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jun 17, 2024
1 parent 2bf946f commit fc80187
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Go to the `v1` branch to see the changelog of Lume 1.

## [2.2.2] - Unreleased
### Fixed
- Apply `mergedKeys` configuration in layouts [#618].
- Extended Preact types with Lume's custom attributes [#619].
- Hot reload: Ensure sockets are open before send updates [#614], [#615].
- Updated dependencies: `tailwindcss`, `terser`, `sass`, `std`, `react-render-to-string`, `xml`, `esbuild`, `vento`, `unocss`.
Expand Down Expand Up @@ -410,6 +411,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
[#610]: https://github.com/lumeland/lume/issues/610
[#614]: https://github.com/lumeland/lume/issues/614
[#615]: https://github.com/lumeland/lume/issues/615
[#618]: https://github.com/lumeland/lume/issues/618
[#619]: https://github.com/lumeland/lume/issues/619

[2.2.2]: https://github.com/lumeland/lume/compare/v2.2.1...HEAD
Expand Down
10 changes: 5 additions & 5 deletions core/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ export default class Renderer {
delete data.layout;
delete data.templateEngine;

data = {
...layoutData,
...data,
content,
};
data = mergeData(
layoutData,
data,
{ content },
) as Data;

content = await this.render<Content>(
layoutData.content,
Expand Down
43 changes: 43 additions & 0 deletions tests/__snapshots__/layout.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ snapshot[`Layouts 1`] = `
src: [
"/",
"/_includes",
"/_includes/layout-2.vto",
"/_includes/layout-3.vto",
"/_includes/page.vto",
"/_includes/style.vto",
"/index.md",
"/page.md",
"/styles.2.css",
"/styles.css",
],
Expand Down Expand Up @@ -160,6 +163,46 @@ snapshot[`Layouts 3`] = `
remote: undefined,
},
},
{
content: "<!DOCTYPE html>
<h2>From Layout 3</h2>
/file-1.css,/file-2.css,/file-3.css
<h2>From Layout 2</h2>
/file-1.css,/file-2.css
<p>Content</p>
",
data: {
basename: "page",
children: "<p>Content</p>
",
content: "Content",
css_file: "Array(1)",
date: [],
layout: "layout-2.vto",
mergedKeys: [
"css_file",
],
page: [
"src",
"data",
"asset",
],
paginate: "paginate",
search: [],
tags: "Array(0)",
url: "/page/",
},
src: {
asset: false,
ext: ".md",
path: "/page",
remote: undefined,
},
},
{
content: "body {
color: blue;
Expand Down
11 changes: 11 additions & 0 deletions tests/assets/layouts/_includes/layout-2.vto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
layout: layout-3.vto
css_file:
- /file-1.css
- /file-2.css
---

<h2>From Layout 2</h2>
{{ css_file.join(",") }}

{{ content }}
11 changes: 11 additions & 0 deletions tests/assets/layouts/_includes/layout-3.vto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
css_file:
- /file-1.css
- /file-2.css
- /file-3.css
---

<h2>From Layout 3</h2>
{{ css_file.join(",") }}

{{ content }}
8 changes: 8 additions & 0 deletions tests/assets/layouts/page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: layout-2.vto
css_file: /file-1.css
mergedKeys:
css_file: stringArray
---

Content

0 comments on commit fc80187

Please sign in to comment.