Files
api-docs/_includes/layout.11ty.js
Matvey Ryabchikov 04a4ea1a81 фикс
2022-08-17 05:51:19 +03:00

32 lines
1.1 KiB
JavaScript

module.exports = {
render(data) {
let content = data.content;
data.collections.all.forEach(
({ url, inputPath }) => (content = content.replaceAll(`href="${inputPath}"`, `href="${url}"`))
);
['GET', 'POST'].forEach(
m => (content = content.replaceAll(m, `<span class="${m.toLowerCase()}">${m}</span>`))
);
return `<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/styles.css">
<link rel="shortcut icon" href="/logo.svg" type="image/svg+xml">
<title>${content.match(/<h1>(.*)<\/h1>/)[0].slice(4, -5)} - Документация SPWorlds</title>
</head>
<body>
<header>
<a href="/">
<img src="/logo.svg" height="42" width="42" alt="" />
Документация API Сайтов СП
</a>
</header>
<main>${content}</main>
</body>
</html>`;
}
};