style: run prettier on pre-commit hook

This commit is contained in:
Stefan Rotsch
2023-06-01 16:43:09 +02:00
committed by Stefan Rotsch
parent b82d5a9da9
commit 9948712690
15 changed files with 50 additions and 45 deletions

View File

@@ -6,8 +6,8 @@ import {
readFileSync,
writeFileSync,
} from "fs";
import { JSDOM } from "jsdom";
import XmlSitemap from "xml-sitemap";
import { JSDOM } from 'jsdom';
import { publicUrl } from "../src/config";
import { createRadar } from "./generateJson/radar";
@@ -44,43 +44,42 @@ const createStaticFiles = async () => {
const sitemapOptions = {
lastmod: "now",
changefreq: "weekly",
}
};
sitemap.add(`${publicUrl}index.html`, sitemapOptions);
radar.items.forEach((item) => {
const targetPath = `build/${item.quadrant}/${item.name}.html`
copyFileSync(
"build/index.html",
targetPath
);
const targetPath = `build/${item.quadrant}/${item.name}.html`;
copyFileSync("build/index.html", targetPath);
JSDOM.fromFile(targetPath).then(dom => {
JSDOM.fromFile(targetPath).then((dom) => {
const document = dom.window.document;
const rootEl = document.getElementById("root")
const rootEl = document.getElementById("root");
if (rootEl) {
const textNode = document.createElement("div")
const textNode = document.createElement("div");
const bodyFragment = JSDOM.fragment(item.body);
textNode.appendChild(bodyFragment)
textNode.appendChild(bodyFragment);
const headlineNode = document.createElement("h1")
const headlineNode = document.createElement("h1");
const titleText = document.createTextNode(item.title);
headlineNode.appendChild(titleText)
headlineNode.appendChild(titleText);
rootEl.appendChild(headlineNode)
rootEl.appendChild(textNode)
rootEl.appendChild(headlineNode);
rootEl.appendChild(textNode);
} else {
console.warn('Element with ID "root" not found. Static site content will be empty.')
console.warn(
'Element with ID "root" not found. Static site content will be empty.'
);
}
writeFileSync(
targetPath,
dom.serialize()
);
writeFileSync(targetPath, dom.serialize());
});
sitemap.add(`${publicUrl}${item.quadrant}/${item.name}.html`, sitemapOptions);
sitemap.add(
`${publicUrl}${item.quadrant}/${item.name}.html`,
sitemapOptions
);
});
writeFileSync("build/sitemap.xml", sitemap.xml);

View File

@@ -5,6 +5,7 @@ import highlight from "highlight.js";
import { marked } from "marked";
import * as path from "path";
import { ConfigData, publicUrl } from "../../src/config";
import {
FlagType,
Item,
@@ -15,8 +16,6 @@ import {
import { appBuild } from "../paths";
import { getAllMarkdownFiles, radarPath } from "./file";
import { ConfigData, publicUrl } from "../../src/config";
marked.setOptions({
highlight: (code: any) => highlight.highlightAuto(code).value,
});
@@ -147,7 +146,7 @@ const addRevisionToItem = (
body: "",
info: "",
angleFraction: Math.random(),
radiusFraction: Math.random()
radiusFraction: Math.random(),
},
revision: Revision
): Item => {

2
scripts/types.d.ts vendored
View File

@@ -1 +1 @@
declare module 'xml-sitemap';
declare module "xml-sitemap";