Migrate from Metalsmith to Smed
This commit is contained in:
parent
afd0d72ce6
commit
a93dadbd32
2 changed files with 13 additions and 51 deletions
13
cv.py
Normal file
13
cv.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from smed import Smed
|
||||
from smed_layouts import layouts
|
||||
from smed_markdown import markdown
|
||||
|
||||
(
|
||||
Smed()
|
||||
.source("./src")
|
||||
.destination("./pub")
|
||||
.static(["*.css", "*.pdf"])
|
||||
.use(markdown())
|
||||
.use(layouts())
|
||||
.build()
|
||||
)
|
||||
51
index.js
51
index.js
|
|
@ -1,51 +0,0 @@
|
|||
var Metalsmith = require("metalsmith");
|
||||
var htmlMinifier = require("metalsmith-html-minifier");
|
||||
var layouts = require("metalsmith-layouts");
|
||||
var markdown = require("metalsmith-markdown-remarkable");
|
||||
var permalinks = require("@metalsmith/permalinks");
|
||||
var static = require("metalsmith-static");
|
||||
var puppeteer = require("puppeteer");
|
||||
|
||||
var srcHTML = "file:" + __dirname + "/pub/index.html";
|
||||
var destPDF = "./pub/cv-anders-englof-ytterstrom.pdf";
|
||||
|
||||
async function generatePDF() {
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto(srcHTML, {
|
||||
waitUntil: "networkidle2",
|
||||
});
|
||||
await page.pdf({
|
||||
path: destPDF,
|
||||
});
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
Metalsmith(__dirname)
|
||||
.source("./src")
|
||||
.destination("./pub")
|
||||
.use(
|
||||
markdown({
|
||||
html: true,
|
||||
typographer: false,
|
||||
}),
|
||||
)
|
||||
.use(permalinks())
|
||||
.use(
|
||||
layouts({
|
||||
engine: "handlebars",
|
||||
}),
|
||||
)
|
||||
.use(htmlMinifier())
|
||||
.use(
|
||||
static({
|
||||
src: "./assets",
|
||||
dest: "./",
|
||||
}),
|
||||
)
|
||||
.build(function (err, _files) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
generatePDF();
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue