Skip to content

Commit c775d54

Browse files
committed
Test page.vars.js layout
1 parent 0b03265 commit c775d54

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

examples/basic/src/js-page/page.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { html } from 'uhtml-isomorphic'
22

33
export default async function JSPage ({
4-
siteName,
5-
title,
4+
vars: {
5+
siteName,
6+
title,
7+
}
68
}) {
79
return html`
8-
<p>The js page is the only page type that can render the body with the set varibles.</p>
10+
<p>The js page is the only page type that can render the body with the set variables.</p>
911
1012
<p>
1113
All you have to do is export a default function (async or sync) that returns a string, or any
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
layout: 'child'
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { html } from 'uhtml-isomorphic'
2+
3+
import defaultRootLayout from './root.layout.js'
4+
5+
export default function articleLayout (args) {
6+
const { children, ...rest } = args
7+
const wrappedChildren = html`
8+
<article class="bc-article h-entry" itemscope itemtype="http://schema.org/NewsArticle">
9+
10+
<h1>${rest.vars.title}</h1>
11+
12+
<section class="e-content" itemprop="articleBody">
13+
${typeof children === 'string'
14+
? html([children])
15+
: children /* Support both uhtml and string children. Optional. */
16+
}
17+
</section>
18+
</article>
19+
`
20+
21+
return defaultRootLayout({ children: wrappedChildren, ...rest })
22+
}
File renamed without changes.

0 commit comments

Comments
 (0)