2023-02-26 01:30
This commit is contained in:
43
lit-element-starter-ts/docs-src/_includes/example.11ty.cjs
Normal file
43
lit-element-starter-ts/docs-src/_includes/example.11ty.cjs
Normal file
@@ -0,0 +1,43 @@
|
||||
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>
|
||||
`;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
module.exports = function (data) {
|
||||
return `
|
||||
<footer>
|
||||
<p>
|
||||
Made with
|
||||
<a href="https://github.com/PolymerLabs/lit-starter-ts">lit-starter-ts</a>
|
||||
</p>
|
||||
</footer>`;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
module.exports = function (data) {
|
||||
return `
|
||||
<header>
|
||||
<h1><my-element></h1>
|
||||
<h2>A web component just for me.</h2>
|
||||
</header>`;
|
||||
};
|
||||
11
lit-element-starter-ts/docs-src/_includes/nav.11ty.cjs
Normal file
11
lit-element-starter-ts/docs-src/_includes/nav.11ty.cjs
Normal file
@@ -0,0 +1,11 @@
|
||||
const relative = require('./relative-path.cjs');
|
||||
|
||||
module.exports = function ({page}) {
|
||||
return `
|
||||
<nav>
|
||||
<a href="${relative(page.url, '/')}">Home</a>
|
||||
<a href="${relative(page.url, '/examples/')}">Examples</a>
|
||||
<a href="${relative(page.url, '/api/')}">API</a>
|
||||
<a href="${relative(page.url, '/install/')}">Install</a>
|
||||
</nav>`;
|
||||
};
|
||||
37
lit-element-starter-ts/docs-src/_includes/page.11ty.cjs
Normal file
37
lit-element-starter-ts/docs-src/_includes/page.11ty.cjs
Normal file
@@ -0,0 +1,37 @@
|
||||
const header = require('./header.11ty.cjs');
|
||||
const footer = require('./footer.11ty.cjs');
|
||||
const nav = require('./nav.11ty.cjs');
|
||||
const relative = require('./relative-path.cjs');
|
||||
|
||||
module.exports = function (data) {
|
||||
const {title, page, content} = data;
|
||||
return `
|
||||
<!doctype html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>${title}</title>
|
||||
<link rel="stylesheet" href="${relative(page.url, '/docs.css')}">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
|
||||
<link href="${relative(page.url, '/prism-okaidia.css')}" rel="stylesheet" />
|
||||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="/node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="${relative(
|
||||
page.url,
|
||||
'/my-element.bundled.js'
|
||||
)}"></script>
|
||||
</head>
|
||||
<body>
|
||||
${header()}
|
||||
${nav(data)}
|
||||
<div id="main-wrapper">
|
||||
<main>
|
||||
${content}
|
||||
</main>
|
||||
</div>
|
||||
${footer()}
|
||||
</body>
|
||||
</html>`;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
const path = require('path').posix;
|
||||
|
||||
module.exports = (base, p) => {
|
||||
const relativePath = path.relative(base, p);
|
||||
if (p.endsWith('/') && !relativePath.endsWith('/') && relativePath !== '') {
|
||||
return relativePath + '/';
|
||||
}
|
||||
return relativePath;
|
||||
};
|
||||
Reference in New Issue
Block a user