Skip to content

Commit

Permalink
Adds write.as importer
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Apr 9, 2021
1 parent 94424e6 commit 4f9aa79
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
38 changes: 38 additions & 0 deletions app/dashboard/routes/importer/sources/write.as/index.js
@@ -0,0 +1,38 @@
const fs = require("fs-extra");
const helper = require("dashboard/routes/importer/helper");
const marked = require("marked");

const input_directory = process.argv[2];
const output_directory = input_directory + "-output";

const posts = fs
.readdirSync(input_directory)
.filter(
(filename) =>
fs.statSync(input_directory + "/" + filename).isFile() &&
filename[0] !== "."
)
.map((filename) => {
let file = fs
.readFileSync(input_directory + "/" + filename, "utf-8")
.trim();
let post = {};

post.title = file.split("\n")[0].slice(2);
post.html = marked(file.split("\n").slice(1).join("\n"));
post.slug = filename.slice(0, filename.indexOf("_"));
post.id = filename.slice(filename.indexOf("_") + 1);
post.permalink = "/" + post.slug;
post.dateStamp = post.created = post.updated = fs
.statSync(input_directory + "/" + filename)
.ctime.valueOf();
post.draft = post.page = false;

return post;
});

console.log(posts);

// Writes each post in the post array,
// downloads any images, pdfs
helper.process(output_directory, posts);
4 changes: 0 additions & 4 deletions todo.txt
@@ -1,7 +1,3 @@
Write write.as import script and follow up with [Michael](https://mail.google.com/mail/u/0/#inbox/FMfcgxwLtQLVmChKwVlgTFqxpTKqrbCQ)

---

Finish NGINX tweaks

Check in on log rotation
Expand Down

0 comments on commit 4f9aa79

Please sign in to comment.