mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
chore(docs): remove cf, posthtml fiiles
This commit is contained in:
parent
f0b270b9bc
commit
d3c89a60c3
7 changed files with 17 additions and 149 deletions
|
@ -2,7 +2,6 @@ const sirv = require("sirv");
|
|||
const polka = require("polka");
|
||||
const { chromium } = require("playwright");
|
||||
const fs = require("fs-extra");
|
||||
const posthtml = require("posthtml");
|
||||
const path = require("path");
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
@ -17,45 +16,17 @@ async function scrape(page, url = "") {
|
|||
return html;
|
||||
}
|
||||
|
||||
function relativePaths(depth = 0) {
|
||||
const asset_extension = new RegExp(/.(js|css|ico)$/);
|
||||
let relative_path = "";
|
||||
|
||||
return (tree) => {
|
||||
tree.match(
|
||||
[
|
||||
{ attrs: { href: asset_extension } },
|
||||
{ attrs: { src: asset_extension } },
|
||||
],
|
||||
(node) => {
|
||||
if ("href" in node.attrs) {
|
||||
node.attrs.href = relative_path + node.attrs.href;
|
||||
}
|
||||
|
||||
if ("src" in node.attrs) {
|
||||
node.attrs.src = relative_path + node.attrs.src;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
);
|
||||
|
||||
tree.match({ attrs: { id: "__routify_iframes" } }, (node) => {});
|
||||
};
|
||||
}
|
||||
|
||||
async function processHtml(html, { dir, outfilePath, depth }) {
|
||||
const processed = await posthtml().use(relativePaths(depth)).process(html);
|
||||
async function processHtml(html, { dir, outfilePath }) {
|
||||
if (dir) {
|
||||
await fs.ensureDir(outfilePath);
|
||||
await fs.writeFile(
|
||||
path.join(outfilePath, "index.html"),
|
||||
await `<!DOCTYPE html><html lang="en">${processed.html}</html>`
|
||||
await `<!DOCTYPE html><html lang="en">${html}</html>`
|
||||
);
|
||||
} else {
|
||||
await fs.writeFile(
|
||||
path.join(outfilePath),
|
||||
await `<!DOCTYPE html><html lang="en">${processed.html}</html>`
|
||||
await `<!DOCTYPE html><html lang="en">${html}</html>`
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -63,7 +34,7 @@ async function processHtml(html, { dir, outfilePath, depth }) {
|
|||
}
|
||||
|
||||
const app = polka()
|
||||
.use(sirv("dist", { single: true }))
|
||||
.use(sirv(OUT_DIR, { single: true }))
|
||||
.listen(PORT, async (error) => {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
|
@ -84,12 +55,10 @@ const app = polka()
|
|||
await processHtml(result, {
|
||||
dir: true,
|
||||
outfilePath: `${OUT_DIR}/${filePath}`,
|
||||
depth: 2,
|
||||
});
|
||||
}
|
||||
|
||||
await fs.ensureDir(`${OUT_DIR}/framed/`);
|
||||
await fs.ensureDir(`${OUT_DIR}/framed/Grid`);
|
||||
|
||||
const framed = [
|
||||
{
|
||||
|
@ -123,7 +92,6 @@ const app = polka()
|
|||
await processHtml(result, {
|
||||
dir: true,
|
||||
outfilePath: `${OUT_DIR}/${filePath}`,
|
||||
depth: 3,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +102,16 @@ const app = polka()
|
|||
const __index = await scrape(page);
|
||||
await processHtml(__index, { outfilePath: `${OUT_DIR}/index.html` });
|
||||
|
||||
await fs.writeFile(
|
||||
path.join(OUT_DIR, "_config.yml"),
|
||||
`include:
|
||||
- _.js
|
||||
- _*.js
|
||||
- assets
|
||||
- assets/*_.js
|
||||
- assets/*.js`
|
||||
);
|
||||
|
||||
await browser.close();
|
||||
await app.server.close();
|
||||
process.exit(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue