import { configuration } from "@codedoc/core"; import { GlobalScripts } from "./plugins/global-scripts"; import { theme } from "./theme"; const fse = require("fs-extra"); const mergeFiles = require('merge-files'); export const config = /*#__PURE__*/configuration({ theme, page: { title: { base: "Tom Riedl", connector: " | " }, meta: { subject: 'Tom Riedl', description: 'Business, Trading, Technik, Programmieren, Software, Kryptow√§hrungen', keywords: ['tom', 'riedl', 'tomriedl', 'binance', 'bitfinex', 'crypto', 'krypto', 'referral', 'affiliate', 'system', 'code', 'partner', 'kryptow√§hrungen', 'apps', 'telegram', 'android', 'ios'], themeColor: "#212121", // --> the browser bar color of your docs appleMobileWebStatusBarStyle: "black-translucent" }, favicon: "/favicon.ico", stylesheets: [ ], fonts: { text: { name: "Hind", url: "", fallback: "sans-serif" }, code: { name: "Source Code Pro", url: "", fallback: `'Courier New', Courier, monospace` }, icon: { name: "Material Icons", url: "", outline: "Material Icons Outlined" }, } }, src: { base: 'docs/md', toc: '_toc.md', not_found: '404.md', pick: /\.md$/, }, dest: { assets: "dist", bundle: "bundle", styles: "styles", html: "dist" }, plugins: [ GlobalScripts() ], afterBuild: [ async function Minify(): Promise { const source: string = "docs/assets/styles.css"; const destination: string = "dist/styles/codedoc-styles.css"; const merged: string = "dist/styles/styles-merged.css"; await mergeFiles([destination, source], merged); await fse.move(merged, destination, { overwrite: true }, (error: any) => { if (error) { console.error(error); } }); }, async function CopyAssets(): Promise { await fse.copy("docs/assets", "dist/assets", { overwrite: true }, (error: any) => { if (error) { console.error(error); } }); await fse.copy("docs/fonts", "dist/fonts", { overwrite: true }, (error: any) => { if (error) { console.error(error); } }); await fse.copy("docs/root", "dist", { overwrite: true }, (error: any) => { if (error) { console.error(error); } }); }, async function CopyVersion1Content(): Promise { await fse.copy("docs/wp-content", "dist/wp-content", { overwrite: true }, (error: any) => { if (error) { console.error(error); } }); }, async function FileOperations(): Promise { const { resolve } = require('path'); const { readdir } = require('fs').promises; async function* getFiles(path: string): any { const directories = await readdir(path, { withFileTypes: true }); for (const directory of directories) { const res = resolve(path, directory.name); if (directory.isDirectory()) { yield* getFiles(res); } else { yield res; } } } async function PostProcessHtml(filepath: string): Promise { fse.readFile(filepath, "utf8", function (error: any, data: any) { if (error) { return console.error("Unable to read file in AddLangToHtml.", error); } let result: string = data.replace(/See/g, 'See'); result = result.replace(/target="_blank"/g, 'target="_blank" rel="noopener"'); result = result.replace(/class="header-0-0/g, 'class="header-0-0-x header-0-0'); result = result.replace(/class="toc-0-0/g, 'class="toc-0-0-x toc-0-0'); result = result.replace(/class="heading-0-0/g, 'class="heading-0-0-x heading-0-0'); result = result.replace(/class="anchor-0-0/g, 'class="anchor-0-0-x anchor-0-0'); result = result.replace(/class="contentnav-0-0/g, 'class="contentnav-0-0-x contentnav-0-0'); result = result.replace(/BINANCE_URL/g, 'https://www.binance.com/de/register?ref=MEA4TAZZ'); result = result.replace(/BITFINEX_URL/g, 'https://www.bitfinex.com/?refcode=yiZ39X8ke'); result = result.replace(/POLONIEX_URL/g, 'https://poloniex.com/signup?c=P3DCTAWA'); result = result.replace(/COINSPOT_URL/g, 'https://www.coinspot.com.au?affiliate=3RQEC'); result = result.replace(/OKEX_URL/g, 'https://www.okex.com/join/1/3066896'); result = result.replace(/SERVERPROFIS_URL/g, 'https://service.serverprofis.net/aff.php?aff=846'); // Free title tag to read it easily from shell script result = result.replace("", "\n<title>"); result = result.replace("", "\n"); // Open all external links in new tabs const linkTags: RegExpMatchArray | null = result.match(/]*href="[^"]*"[^>]*>/gm); for (const tag of linkTags || []) { const uri: RegExpMatchArray | null = tag.match(/.*href="([^"]*)".*/); if (uri && uri.length >= 2) { const href: string = uri[1]; if (href && href[0] != "/" && href[0] != "#" && href.indexOf("https://tomriedl.com") < 0 && tag.lastIndexOf("\">") == tag.length - 2) { const search: string = tag.substring(0, tag.length - 2); const replace: string = `${search}" rel="nofollow" onclick="window.open(this.href);return false`; result = result.replace(search, replace); } } } // Replace tags const tagsCode: RegExpMatchArray | null = result.match(/##Tags##:(.*?)<\/code>/gm); for (const codeBlock of tagsCode || []) { const tags: string = codeBlock.replace("##Tags##:", "").replace("", "").replace(",", " ").trim(); const tagList: Array = tags.toLowerCase().split(" "); const replacementTags: Array = []; for (const rawTag of tagList) { const tag = rawTag.trim(); replacementTags.push(`${tag}`); } const replacement: string = `Tags: \n${replacementTags.join(" · \n")}\n`; result = result.replace(codeBlock, replacement); } // Extract first image to add it to og:image const imageUrls: Array | undefined = result.match(/]*src="[^"]*"[^>]*>/gm)?.map((x: string) => x.replace(/.*src="([^"]*)".*/, '$1')); const coverImage: string = imageUrls && imageUrls.length ? imageUrls[0] : ""; if (coverImage) { result = result.replace(' { if (error) { console.error(error); } }); break; } } for await (const filepath of getFiles("dist")) { const extension: string = filepath.split(".").pop(); switch (extension) { case "html": await PostProcessHtml(filepath); break; } } } ], });