summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-01-21 19:08:31 +0100
committerMinteck <contact@minteck.org>2022-01-21 19:08:31 +0100
commitb0e05b2a7ba1c0683c376c192d7d3abcbad2a0f4 (patch)
treec8894a68971b3d17220a13a153b98d1b2bd2e5d8
parent3a04cb197f152f171fba679663a91a9bb61d710e (diff)
downloadcobalt-b0e05b2a7ba1c0683c376c192d7d3abcbad2a0f4.tar.gz
cobalt-b0e05b2a7ba1c0683c376c192d7d3abcbad2a0f4.tar.bz2
cobalt-b0e05b2a7ba1c0683c376c192d7d3abcbad2a0f4.zip
Fix issue with Android (and potentially Linux)
-rw-r--r--.idea/.gitignore5
-rw-r--r--.idea/DocCMS.iml12
-rw-r--r--.idea/deployment.xml14
-rw-r--r--.idea/jsLibraryMappings.xml6
-rw-r--r--.idea/modules.xml8
-rw-r--r--.idea/vcs.xml6
-rw-r--r--index.js9
-rw-r--r--modules/publishtag.js13
8 files changed, 57 insertions, 16 deletions
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..b58b603
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/DocCMS.iml b/.idea/DocCMS.iml
new file mode 100644
index 0000000..0c8867d
--- /dev/null
+++ b/.idea/DocCMS.iml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$">
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module> \ No newline at end of file
diff --git a/.idea/deployment.xml b/.idea/deployment.xml
new file mode 100644
index 0000000..1436779
--- /dev/null
+++ b/.idea/deployment.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
+ <serverData>
+ <paths name="Familine">
+ <serverdata>
+ <mappings>
+ <mapping local="$PROJECT_DIR$" web="/" />
+ </mappings>
+ </serverdata>
+ </paths>
+ </serverData>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
new file mode 100644
index 0000000..d23208f
--- /dev/null
+++ b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="JavaScriptLibraryMappings">
+ <includedPredefinedLibrary name="Node.js Core" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..3498600
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/DocCMS.iml" filepath="$PROJECT_DIR$/.idea/DocCMS.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/index.js b/index.js
index d63ec35..40fbe23 100644
--- a/index.js
+++ b/index.js
@@ -186,13 +186,14 @@ for (let dir of directories) {
console.log("Rendering pages...");
for (let page of files) {
- content = md.render(fs.readFileSync(page.source).toString());
+ content = md.render(fs.readFileSync(page.source).toString()).replace(/---\n((.|\n)*)\n---/gm, "").trim();
+ if (!fs.existsSync(path.dirname(page.dest))) fs.mkdirSync(path.dirname(page.dest));
fs.writeFileSync(page.dest, ejs.render(header, {config, name: page.name}) + "<header class=\"" + config.classes.header.join(" ") + "\"><a href=\"." + page.parent.path + "\">« " + page.parent.name + "</a><hr></header><article class=\"" + config.classes.article.join(" ") + "\">" + content + "</article>" + ejs.render(footer, {config, name: page.name}));
}
console.log("Generating home page...");
if (fs.existsSync("./data/index.md")) {
- content = md.render(fs.readFileSync("./data/index.md").toString()) + "<hr>";
+ content = md.render(fs.readFileSync("./data/index.md").toString()).replace(/---\n((.|\n)*)\n---/gm, "").trim() + "<hr>";
} else {
content = "";
}
@@ -207,7 +208,7 @@ for (let dir of directories) {
removeFromSitemap(dir.id);
console.log("Generating home page...");
if (fs.existsSync("./data/index.md")) {
- content = md.render(fs.readFileSync("./data/index.md").toString()) + "<hr>";
+ content = md.render(fs.readFileSync("./data/index.md").toString()).replace(/---\n((.|\n)*)\n---/gm, "").trim() + "<hr>";
} else {
content = "";
}
@@ -216,7 +217,7 @@ for (let dir of directories) {
}
} else {
if (sitemaps[dir.id].trim() !== "") {
- fs.writeFileSync(dir.dest + "/index.html", ejs.render(header, {config, name: dir.name}) + "<header class=\"" + config.classes.header.join(" ") + "\"><a href=\"../index.html\">« index</a><hr></header><article class=\"" + config.classes.article.join(" ") + "\">" + md.render(fs.readFileSync(dir.source + "/index.md").toString()) + "<hr>" + md.render(sitemaps[dir.id]) + "</article>" + ejs.render(footer, {config, name: dir.name}));
+ fs.writeFileSync(dir.dest + "/index.html", ejs.render(header, {config, name: dir.name}) + "<header class=\"" + config.classes.header.join(" ") + "\"><a href=\"../index.html\">« index</a><hr></header><article class=\"" + config.classes.article.join(" ") + "\">" + md.render(fs.readFileSync(dir.source + "/index.md").toString()).replace(/---\n((.|\n)*)\n---/gm, "").trim() + "<hr>" + md.render(sitemaps[dir.id]) + "</article>" + ejs.render(footer, {config, name: dir.name}));
}
}
} \ No newline at end of file
diff --git a/modules/publishtag.js b/modules/publishtag.js
index 9828443..8f0baa2 100644
--- a/modules/publishtag.js
+++ b/modules/publishtag.js
@@ -1,16 +1,5 @@
const fs = require('fs');
module.exports = (file) => {
- file = fs.readFileSync(file).toString();
- try {
- frontmatter = file.split("---")[1].trim()
- lines = frontmatter.replaceAll("\r\n", "\n").split("\n");
- if (lines.map(i => i.trim()).includes("publish: true") || lines.map(i => i.trim()).includes("publish : true") || lines.map(i => i.trim()).includes("publish :true")) {
- return true;
- } else {
- return false;
- }
- } catch (e) {
- return false;
- }
+ return fs.readFileSync(file).toString().match(/---\n(.*)\npublish( *):( *)true\n(.*)---/gm)
} \ No newline at end of file