Skip to content

Commit 485c6fa

Browse files
committed
Commiting editor syntax changes
- my editor automatically did this...
1 parent b47757d commit 485c6fa

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

add-random-posts.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* node add-random-posts.js https://blah.ghost.io ADMIN_API_KEY number_of_posts
77
*/
8-
if (process.argv.length < 4) {
8+
if (process.argv.length < 5) {
99
console.error('Missing an argument');
1010
process.exit(1);
1111
}
@@ -25,35 +25,35 @@ const api = new GhostAdminAPI({
2525
url,
2626
key,
2727
version: 'v2'
28-
});
28+
});
2929

3030
(async function main() {
3131
try {
32-
const posts = [];
32+
const posts = [];
3333

3434
_.times(count, () => {
3535
let post = {
3636
status: 'published',
3737
title: loremIpsum({
3838
count: 2,
39-
units: 'words',
39+
units: 'words'
4040
}),
4141
excerpt: loremIpsum({
4242
count: 2,
4343
units: 'sentences'
4444
}),
4545
html: loremIpsum({
46-
count: 400, // Number of "words", "sentences", or "paragraphs"
47-
format: 'html', // "plain" or "html"
48-
paragraphLowerBound: 3, // Min. number of sentences per paragraph.
49-
paragraphUpperBound: 7, // Max. number of sentences per paragarph.
50-
random: Math.random, // A PRNG function
51-
sentenceLowerBound: 3, // Min. number of words per sentence.
52-
sentenceUpperBound: 15, // Max. number of words per sentence.
53-
suffix: '\n', // Line ending, defaults to "\n" or "\r\n" (win32)
54-
units: 'paragraphs', // paragraph(s), "sentence(s)", or "word(s)"
55-
words: undefined // Array of words to draw from
56-
}),
46+
count: 400, // Number of "words", "sentences", or "paragraphs"
47+
format: 'html', // "plain" or "html"
48+
paragraphLowerBound: 3, // Min. number of sentences per paragraph.
49+
paragraphUpperBound: 7, // Max. number of sentences per paragarph.
50+
random: Math.random, // A PRNG function
51+
sentenceLowerBound: 3, // Min. number of words per sentence.
52+
sentenceUpperBound: 15, // Max. number of words per sentence.
53+
suffix: '\n', // Line ending, defaults to "\n" or "\r\n" (win32)
54+
units: 'paragraphs', // paragraph(s), "sentence(s)", or "word(s)"
55+
words: undefined // Array of words to draw from
56+
})
5757

5858
};
5959

@@ -64,7 +64,6 @@ const api = new GhostAdminAPI({
6464

6565
// convert our list of posts, to a list of promises for requests to the api
6666
const result = await Promise.mapSeries(posts, async (post) => {
67-
6867
console.log('Adding', post.title);
6968
// Call the API
7069
let result = await api.posts.add(post, {source: 'html'});
@@ -74,7 +73,6 @@ const api = new GhostAdminAPI({
7473
});
7574

7675
console.log(`Added ${result.length} posts`);
77-
7876
} catch (err) {
7977
console.error('There was an error', require('util').inspect(err, false, null));
8078
process.exit(1);

add-tag-to-all-posts.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,22 @@ const api = new GhostAdminAPI({
2323
url,
2424
key,
2525
version: 'v2'
26-
});
26+
});
2727

2828
(async function main() {
2929
try {
3030
console.log(`Adding tag ${tag} to ${url}`);
3131

32-
const tagToAdd = await api.tags.read({ slug: tag });
32+
const tagToAdd = await api.tags.read({slug: tag});
3333

3434
console.log('Found tag', tagToAdd);
3535

3636
// Admin API automatically includes tags and authors
3737
// WARNING: If the site is really big (1000s of posts) maybe do this paginated
38-
const allPosts = await api.posts.browse({ limit: 'all' });
38+
const allPosts = await api.posts.browse({limit: 'all'});
3939

4040
// convert our list of posts, to a list of promises for requests to the api
4141
const result = await Promise.mapSeries(allPosts, async (post) => {
42-
4342
// Add the tag to the post
4443
post.tags.push(tagToAdd);
4544

@@ -56,7 +55,6 @@ const api = new GhostAdminAPI({
5655
});
5756

5857
console.log(`Updated ${result.length} posts`);
59-
6058
} catch (err) {
6159
console.error('There was an error', require('util').inspect(err, false, null));
6260
process.exit(1);

0 commit comments

Comments
 (0)