Skip to content

Commit

Permalink
Test page.vars.js layout
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Jan 26, 2025
1 parent 0b03265 commit c775d54
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/basic/src/js-page/page.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { html } from 'uhtml-isomorphic'

export default async function JSPage ({
siteName,
title,
vars: {
siteName,
title,
}
}) {
return html`
<p>The js page is the only page type that can render the body with the set varibles.</p>
<p>The js page is the only page type that can render the body with the set variables.</p>
<p>
All you have to do is export a default function (async or sync) that returns a string, or any
Expand Down
3 changes: 3 additions & 0 deletions examples/basic/src/js-page/page.vars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
layout: 'child'
}
22 changes: 22 additions & 0 deletions examples/basic/src/layouts/child.layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { html } from 'uhtml-isomorphic'

import defaultRootLayout from './root.layout.js'

export default function articleLayout (args) {
const { children, ...rest } = args
const wrappedChildren = html`
<article class="bc-article h-entry" itemscope itemtype="http://schema.org/NewsArticle">
<h1>${rest.vars.title}</h1>
<section class="e-content" itemprop="articleBody">
${typeof children === 'string'
? html([children])
: children /* Support both uhtml and string children. Optional. */
}
</section>
</article>
`

return defaultRootLayout({ children: wrappedChildren, ...rest })
}
File renamed without changes.

0 comments on commit c775d54

Please sign in to comment.