forked from lit/lit-element-starter-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.11ty.cjs
35 lines (32 loc) · 905 Bytes
/
example.11ty.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const page = require('./page.11ty.cjs');
const relative = require('./relative-path.cjs');
/**
* This template extends the page template and adds an examples list.
*/
module.exports = function(data) {
return page({
...data,
content: renderExample(data),
});
};
const renderExample = ({name, content, collections, page}) => {
return `
<h1>Example: ${name}</h1>
<section class="examples">
<nav class="collection">
<ul>
${collections.example === undefined
? ''
: collections.example.map((post) => `
<li class=${post.url === page.url ? 'selected' : ''}>
<a href="${relative(page.url, post.url)}">${post.data.description.replace('<', '<')}</a>
</li>
`).join('')}
</ul>
</nav>
<div>
${content}
</div>
</section>
`;
};