Skip to content

Commit d6a6ce0

Browse files
committedNov 13, 2017
Edit: Remove slug from comments
1 parent e83c021 commit d6a6ce0

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pids
1313
*.pid.lock
1414
.todo.md
1515

16+
bin/
1617
comments/
1718
wp.xml
1819

‎cli.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ let i = 0;
1313

1414
console.log('Starting to find comments...');
1515

16-
const createFile = c => {
16+
const createFile = (c, slug) => {
1717
const timestamp = new Date(c.date).getTime();
18-
const filename = path.join(args[1], '/comments/', c.slug,
18+
const filename = path.join(args[1], '/comments/', slug,
1919
'/comment-' + timestamp + '.yml');
2020
const fileInput = yaml.safeDump(c);
2121

2222
fspath.writeFile(path.resolve(filename), fileInput, err => {
2323
i += 1;
2424
console.log(`Adding comment ${i}, by ${c.name}...`);
25+
console.log(`To: ${filename}`);
2526
if (err) {
2627
throw err;
2728
}
@@ -36,22 +37,14 @@ const parseComments = (comments, slug) => {
3637

3738
if (comment['wp:comment_approved'][0] === '1') {
3839
const commentObj = {
39-
slug,
4040
name: comment['wp:comment_author'][0],
4141
date: comment['wp:comment_date'][0],
4242
url: comment['wp:comment_author_url'][0],
4343
message: comment['wp:comment_content'][0],
4444
email: md5(comment['wp:comment_author_email'][0])
4545
};
4646

47-
createFile(commentObj);
48-
/* Filter by length ?
49-
if(commentObj.message.length<50) {
50-
console.log(commentObj)
51-
i += 1
52-
console.log('I', i)
53-
54-
} */
47+
createFile(commentObj, slug);
5548
}
5649
}
5750
}

‎package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wordpress-comments-jekyll-staticman",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Convert Wordpress comment into Jekyll for Staticman.",
55
"main": "cli.js",
66
"scripts": {
@@ -10,7 +10,9 @@
1010
"type": "git",
1111
"url": "git+https://github.com/arthurlacoste/wordpress-comments-jekyll-staticman.git"
1212
},
13-
"bin": "cli.js",
13+
"bin": {
14+
"wp2sm": "cli.js"
15+
},
1416
"keywords": [
1517
"wordpress",
1618
"jekyll",

‎readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ npm i wordpress-comments-jekyll-staticman -g
1717
First, import your comments from WordPress with the built-in export tool, then launch this command:
1818

1919
```terminal
20-
wordpress-comments-jekyll-staticman {{ xml file }} {{ folder for comments }}
20+
wp2sm {{ xml file }} {{ folder for comments }}
2121
```
2222

2323
Example:
2424

2525
```terminal
26-
wordpress-comments-jekyll-staticman comments.xml /my/folder
26+
wp2sm comments.xml /my/folder
2727
```
2828

2929
## Staticman settings

0 commit comments

Comments
 (0)