convert builder script to use ESM (very slick)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
3dd9ceb9b8
commit
fa22a8b91d
@ -40,7 +40,7 @@
|
|||||||
media="screen"
|
media="screen"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="/css/site.css?1678238513510"
|
href="/css/site.css?1678239113605"
|
||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
property="title"
|
property="title"
|
||||||
|
14
index.js
14
index.js
@ -1,9 +1,9 @@
|
|||||||
const cheerio = require("cheerio");
|
import { load } from "cheerio";
|
||||||
const fs = require("fs");
|
import { readFile, writeFile } from "fs";
|
||||||
const stores = require("./stores.json");
|
import stores from "./stores.json" assert { type: "json" };
|
||||||
|
|
||||||
function TableViewTemplate(rows) {
|
function TableViewTemplate(rows) {
|
||||||
table = "<table>";
|
let table = "<table>";
|
||||||
rows.forEach((row, key) => {
|
rows.forEach((row, key) => {
|
||||||
row.rowNumber = key;
|
row.rowNumber = key;
|
||||||
table = table + TableRowTemplate(row);
|
table = table + TableRowTemplate(row);
|
||||||
@ -19,11 +19,11 @@ function TableRowTemplate({ rowNumber, name, address, city }) {
|
|||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readFile("./index.html", function (err, data) {
|
readFile("./index.html", function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
const $ = cheerio.load(data);
|
const $ = load(data);
|
||||||
|
|
||||||
stores.sort(function (a, b) {
|
stores.sort(function (a, b) {
|
||||||
var aname = a.name.toLowerCase();
|
var aname = a.name.toLowerCase();
|
||||||
@ -42,7 +42,7 @@ fs.readFile("./index.html", function (err, data) {
|
|||||||
);
|
);
|
||||||
const cssurl = $("link[type='text/css']").attr("href").split("?")[0];
|
const cssurl = $("link[type='text/css']").attr("href").split("?")[0];
|
||||||
$("link[type='text/css']").attr("href", cssurl + "?" + new Date().getTime());
|
$("link[type='text/css']").attr("href", cssurl + "?" + new Date().getTime());
|
||||||
fs.writeFile("./index.html", $.html(), (err) => {
|
writeFile("./index.html", $.html(), (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
console.log("Default view updated.");
|
console.log("Default view updated.");
|
||||||
});
|
});
|
||||||
|
@ -15,5 +15,6 @@
|
|||||||
"homepage": "https://www.nycbookstores.org/",
|
"homepage": "https://www.nycbookstores.org/",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^1.0.0-rc.12"
|
"cheerio": "^1.0.0-rc.12"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user