Created
October 29, 2019 10:19
-
-
Save zeropaper/725e5deacbacef28e1e8415ed04e94aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const renderScreenshot = ({ | |
title = '', | |
slug = '', | |
pageIndex = 0, | |
screenshotPath = '', | |
description = '', | |
}) => `<figure id="${slug}-${pageIndex}"> | |
<img src="${screenshotPath}" title="${title}" /> | |
<figcaption>${description}</figcaption> | |
</figure>`; | |
const renderSection = ({ | |
title = '', | |
slug = '', | |
screenshots = [], | |
}) => `<section id="${slug}"> | |
<header> | |
<h1>${title}</h1> | |
</header> | |
<div class="content"> | |
<div class="screenshots"> | |
${screenshots.map(renderScreenshot).join('\n')} | |
</div> | |
<div class="description"> | |
</div> | |
</div> | |
</div> | |
</section>`; | |
module.exports = async ({ | |
title = 'Documentation', | |
info = {}, | |
} = {}) => `<html> | |
<head> | |
<title>${title}</title> | |
<style> | |
section .content { | |
display: flex; | |
} | |
section .screenshots, | |
section .description { | |
flex-grow: 1; | |
width: 50%; | |
} | |
section figure, | |
section img { | |
max-width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<header> | |
<h1>${title}</h1> | |
</header> | |
${info.map(renderSection).join('\n')} | |
</body> | |
</html>`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment