sveldoc
Version:
Readme-driven Development for building Svelte components
43 lines (42 loc) • 1.63 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.pluginIndex = void 0;
const github_markdown_1 = require("./styles/github-markdown");
const sveldoc_1 = require("./styles/sveldoc");
const get_package_json_1 = require("./utils/get-package-json");
const match_1 = require("./utils/match");
const pluginIndex = (options) => {
const package_json = (0, get_package_json_1.getPackageJson)();
return {
name: "vite:index",
transformIndexHtml(html, ctx) {
var _a;
const is_main_index = match_1.match.indexFile(ctx.filename);
const styles = options.resetStyles
? ""
: (0, github_markdown_1.github_styles)({ is_iframe: !is_main_index }) + sveldoc_1.sveldoc_styles;
const metadata = is_main_index
? `
<meta name="robots" content="index, follow">
<title>${package_json.name}</title>
<meta name="description" content="${package_json.description}" />
`
: "";
return `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
${metadata}
<style>${styles}${(_a = (is_main_index && options.styles)) !== null && _a !== void 0 ? _a : ""}</style>
</head>
<body ${options.resetStyles ? "" : 'class="markdown-body"'}>
${html}
</body>
</html>
`;
},
};
};
exports.pluginIndex = pluginIndex;
;