From 1c42ab628e321468a4f104a3dc5b7e5584e2b167 Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Thu, 31 Aug 2023 09:31:42 +0200 Subject: [PATCH] feat(app): Add webpage generator --- .github/workflows/ci.yml | 18 +++++ .gitignore | 2 + scripts/generate.mjs | 40 ++++++++++ scripts/package-lock.json | 127 ++++++++++++++++++++++++++++++++ scripts/package.json | 19 +++++ template.html | 149 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 355 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 scripts/generate.mjs create mode 100644 scripts/package-lock.json create mode 100644 scripts/package.json create mode 100644 template.html diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4f1f206 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: CI +on: + push: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: cd scripts + - run: npm install + - run: npm run build + - name: Deploy + uses: JamesIves/github-pages-deploy-action@4.1.1 + with: + branch: gh-pages + folder: dist diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b36c8b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +dist +scripts/node_modules diff --git a/scripts/generate.mjs b/scripts/generate.mjs new file mode 100644 index 0000000..f9b88c9 --- /dev/null +++ b/scripts/generate.mjs @@ -0,0 +1,40 @@ +import { promises as fs } from "fs"; +import hljs from "highlight.js"; +import { Marked } from "marked"; +import { gfmHeadingId } from "marked-gfm-heading-id"; +import { markedHighlight } from "marked-highlight"; +import { markedSmartypants } from "marked-smartypants"; + +const marked = new Marked( + gfmHeadingId(), + markedSmartypants(), + markedHighlight({ + langPrefix: "hljs language-", + highlight(code, lang) { + const language = hljs.getLanguage(lang) ? lang : "plaintext"; + return hljs.highlight(code, { language }).value; + }, + }) +); + +(async () => { + const template = await fs.readFile("../template.html", "utf-8"); + let markdown = await fs.readFile("../README.md", "utf-8"); + // Remove first line + markdown = markdown.substring(markdown.indexOf("\n") + 1); + // Remove license section + const licenseLine = "## 📄 License"; + markdown = markdown.substring(0, markdown.indexOf(licenseLine)); + // Replace "- [x] " with "✅ " + markdown = markdown.replaceAll("- [x] ", "- "); + + const html = marked.parse(markdown, { gfm: true }); + const output = template.replace("", html); + await fs.mkdir("../dist", { recursive: true }); + await fs.writeFile("../dist/index.html", output); +})() + .then(() => console.log("Completed!")) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/package-lock.json b/scripts/package-lock.json new file mode 100644 index 0000000..a982fb8 --- /dev/null +++ b/scripts/package-lock.json @@ -0,0 +1,127 @@ +{ + "name": "deliverabilityguide.com-scripts", + "version": "0.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "deliverabilityguide.com-scripts", + "version": "0.0.0", + "license": "MIT", + "dependencies": { + "highlight.js": "^11.8.0", + "marked": "^7.0.5", + "marked-gfm-heading-id": "^3.0.6", + "marked-highlight": "^2.0.4", + "marked-smartypants": "^1.1.0" + } + }, + "node_modules/github-slugger": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz", + "integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==" + }, + "node_modules/highlight.js": { + "version": "11.8.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.8.0.tgz", + "integrity": "sha512-MedQhoqVdr0U6SSnWPzfiadUcDHfN/Wzq25AkXiQv9oiOO/sG0S7XkvpFIqWBl9Yq1UYyYOOVORs5UW2XlPyzg==", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/marked": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/marked/-/marked-7.0.5.tgz", + "integrity": "sha512-lwNAFTfXgqpt/XvK17a/8wY9/q6fcSPZT1aP6QW0u74VwaJF/Z9KbRcX23sWE4tODM+AolJNcUtErTkgOeFP/Q==", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 16" + } + }, + "node_modules/marked-gfm-heading-id": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/marked-gfm-heading-id/-/marked-gfm-heading-id-3.0.6.tgz", + "integrity": "sha512-ot/iTTxvSJpUWv+DJ5aGVj2kxdEpsiKj6NJy6icwcdrVPHsbAE3dZ3Usk4ORt8ke2HKbw83n5Q5jNwSMuAYMSA==", + "dependencies": { + "github-slugger": "^2.0.0" + }, + "peerDependencies": { + "marked": "^4 || ^5 || ^6 || ^7" + } + }, + "node_modules/marked-highlight": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/marked-highlight/-/marked-highlight-2.0.4.tgz", + "integrity": "sha512-hnm+rY3p+DQlSd2uY3zSXec+1kq5x9lD3+PWOMz0ROcil4Btcbt///Fto52jqWWt7XBGiTRk+1+w2rGfx2U2Sw==", + "peerDependencies": { + "marked": "^4 || ^5 || ^6 || ^7" + } + }, + "node_modules/marked-smartypants": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/marked-smartypants/-/marked-smartypants-1.1.0.tgz", + "integrity": "sha512-7pu/8Zpr8rWIXmtab8XPleNuaD+xZ5DQRfjGp3pqAo+SmmDBZ66+fAn5CSQPysAwBzd/qrpOmLg7KSRlwyPHKA==", + "dependencies": { + "smartypants": "^0.2.2" + }, + "peerDependencies": { + "marked": "^4 || ^5 || ^6 || ^7" + } + }, + "node_modules/smartypants": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/smartypants/-/smartypants-0.2.2.tgz", + "integrity": "sha512-TzobUYoEft/xBtb2voRPryAUIvYguG0V7Tt3de79I1WfXgCwelqVsGuZSnu3GFGRZhXR90AeEYIM+icuB/S06Q==", + "bin": { + "smartypants": "bin/smartypants.js", + "smartypantsu": "bin/smartypantsu.js" + } + } + }, + "dependencies": { + "github-slugger": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz", + "integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==" + }, + "highlight.js": { + "version": "11.8.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.8.0.tgz", + "integrity": "sha512-MedQhoqVdr0U6SSnWPzfiadUcDHfN/Wzq25AkXiQv9oiOO/sG0S7XkvpFIqWBl9Yq1UYyYOOVORs5UW2XlPyzg==" + }, + "marked": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/marked/-/marked-7.0.5.tgz", + "integrity": "sha512-lwNAFTfXgqpt/XvK17a/8wY9/q6fcSPZT1aP6QW0u74VwaJF/Z9KbRcX23sWE4tODM+AolJNcUtErTkgOeFP/Q==" + }, + "marked-gfm-heading-id": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/marked-gfm-heading-id/-/marked-gfm-heading-id-3.0.6.tgz", + "integrity": "sha512-ot/iTTxvSJpUWv+DJ5aGVj2kxdEpsiKj6NJy6icwcdrVPHsbAE3dZ3Usk4ORt8ke2HKbw83n5Q5jNwSMuAYMSA==", + "requires": { + "github-slugger": "^2.0.0" + } + }, + "marked-highlight": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/marked-highlight/-/marked-highlight-2.0.4.tgz", + "integrity": "sha512-hnm+rY3p+DQlSd2uY3zSXec+1kq5x9lD3+PWOMz0ROcil4Btcbt///Fto52jqWWt7XBGiTRk+1+w2rGfx2U2Sw==", + "requires": {} + }, + "marked-smartypants": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/marked-smartypants/-/marked-smartypants-1.1.0.tgz", + "integrity": "sha512-7pu/8Zpr8rWIXmtab8XPleNuaD+xZ5DQRfjGp3pqAo+SmmDBZ66+fAn5CSQPysAwBzd/qrpOmLg7KSRlwyPHKA==", + "requires": { + "smartypants": "^0.2.2" + } + }, + "smartypants": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/smartypants/-/smartypants-0.2.2.tgz", + "integrity": "sha512-TzobUYoEft/xBtb2voRPryAUIvYguG0V7Tt3de79I1WfXgCwelqVsGuZSnu3GFGRZhXR90AeEYIM+icuB/S06Q==" + } + } +} diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 0000000..5d7f755 --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,19 @@ +{ + "name": "deliverabilityguide.com-scripts", + "type": "module", + "version": "0.0.0", + "main": "index.mjs", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "Anand Chowdhary ", + "license": "MIT", + "dependencies": { + "highlight.js": "^11.8.0", + "marked": "^7.0.5", + "marked-gfm-heading-id": "^3.0.6", + "marked-highlight": "^2.0.4", + "marked-smartypants": "^1.1.0" + } +} diff --git a/template.html b/template.html new file mode 100644 index 0000000..b2f9c38 --- /dev/null +++ b/template.html @@ -0,0 +1,149 @@ + + + + + Deliverability Guide by FirstQuadrant + + + + + + +
+ +

The open source email

+

Deliverability Guide

+

by FirstQuadrant

+
+
+ +
+ + +