Skip to content

Commit

Permalink
feat: update dependencies & modernize code
Browse files Browse the repository at this point in the history
  • Loading branch information
finalchild committed Jan 6, 2024
1 parent 37a01c1 commit 3a26bb6
Show file tree
Hide file tree
Showing 4 changed files with 458 additions and 806 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ deploy:
github-token: $GITHUB_TOKEN
keep-history: true
on:
branch: master
branch: main
local-dir: ./generated
19 changes: 10 additions & 9 deletions markcafe.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import MarkdownIt from 'markdown-it';
import containerPlugin from 'markdown-it-container';
import fs from 'fs-extra';
import path from 'path';
import fs from 'node:fs/promises';
import fse from 'fs-extra/esm';
import path from 'node:path';
import juice from 'juice';

const template1Start = `<div class="container">`;
const template1End = `</div>`
const template1End = `</div>`;

const template2Start = `<!DOCTYPE html>
<html>
Expand All @@ -32,7 +33,7 @@ const template2End = `
main();

async function main() {
const config = await fs.readJson('./markcafe-config.json', 'utf8');
const config = await fse.readJson('./markcafe-config.json', 'utf8');
if (config.generatedDirectoryPath.endsWith('/')) config.generatedDirectoryPath = config.generatedDirectoryPath.slice(0, str.length - 1);
if (!config.imgSrcPrefix.endsWith('/')) config.imgSrcPrefix += '/';
const md = new MarkdownIt(config.markdownItOptions).use(containerPlugin, 'tip', {
Expand Down Expand Up @@ -60,10 +61,10 @@ async function main() {
return result;
};

await fs.emptyDir(config.generatedDirectoryPath);
await fse.emptyDir(config.generatedDirectoryPath);

const promises = [];
promises.push(fs.copy(config.imagesDirectoryPath, path.join(config.generatedDirectoryPath, 'images')));
promises.push(fse.copy(config.imagesDirectoryPath, path.join(config.generatedDirectoryPath, 'images')));
if (typeof config.cname === 'string' && config.cname !== '') {
promises.push(fs.writeFile(path.join(config.generatedDirectoryPath, 'CNAME'), config.cname + '\n'));
}
Expand All @@ -89,12 +90,12 @@ async function convertFile(md, css, srcPath, targetTxtPath, targetHtmlPath) {
preserveImportant: false,
preserveMediaQueries: false,
preserveKeyFrames: false,
preservePseudos: false
preservePseudos: false,
});
const templated2 = template2Start + juiced + template2End;

await Promise.all([
fs.writeFile(targetTxtPath, juiced),
fs.writeFile(targetHtmlPath, templated2)
fs.writeFile(targetHtmlPath, templated2),
]);
}
Loading

0 comments on commit 3a26bb6

Please sign in to comment.