eleventy-generate-posts 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Changelog
2
2
 
3
- ## 20230701
3
+ ## 20240109 (v0.0.5)
4
+
5
+ Added `-g` parameter used to append generator content to the end of generated posts:
6
+
7
+ > Post content generated by [Eleventy Generate Posts](https://www.npmjs.com/package/eleventy-generate-posts).
8
+
9
+ ## 20230709 - version 0.0.4
10
+
11
+ Made number of posts the first prompt, it seemed better this way.
12
+
13
+ ## 20230701 - version 0.0.3
4
14
 
5
15
  Replaced command line options with interactive prompts
6
16
 
@@ -16,6 +16,7 @@ var HighlightType;
16
16
  const APP_NAME = '11ty Generate Posts';
17
17
  const APP_AUTHOR = 'by John M. Wargo (https://johnwargo.com)\n';
18
18
  const ELEVENTY_FILES = ['.eleventy.js', 'eleventy.config.js'];
19
+ const GENERATOR_CONTENT = '***\n\nPost content generated by [Eleventy Generate Posts](https://www.npmjs.com/package/eleventy-generate-posts)';
19
20
  const NEW_LINE = "\n";
20
21
  const spaces40 = '-'.repeat(40);
21
22
  const red = HighlightType.Red;
@@ -69,37 +70,38 @@ if (!checkEleventyProject()) {
69
70
  }
70
71
  console.log(boxen(APP_NAME, { padding: 1 }));
71
72
  console.log(APP_AUTHOR);
73
+ console.log('Add -d to command to enable debug mode, -g to append generator info to post files.\n');
72
74
  const debugMode = process.argv.includes('-d');
73
75
  if (debugMode) {
74
76
  writeConsole(green, 'Debug mode', 'enabled\n');
75
77
  }
76
78
  log.level(debugMode ? log.DEBUG : log.INFO);
79
+ const generatorInfo = process.argv.includes('-g');
80
+ if (generatorInfo) {
81
+ writeConsole(green, 'Generator info', 'will be added to post files\n');
82
+ }
77
83
  const questions = [
78
- {
79
- type: 'text',
80
- name: 'targetFolder',
81
- initial: 'src/posts',
82
- message: 'Target folder for generated posts?'
83
- },
84
84
  {
85
85
  type: 'number',
86
86
  name: 'numPosts',
87
87
  initial: 10,
88
88
  message: 'Number of posts to generate?'
89
- },
90
- {
89
+ }, {
90
+ type: 'text',
91
+ name: 'targetFolder',
92
+ initial: 'src/posts',
93
+ message: 'Target folder for generated posts?'
94
+ }, {
91
95
  type: 'text',
92
96
  name: 'tag',
93
97
  message: 'Post tag?',
94
98
  initial: 'post'
95
- },
96
- {
99
+ }, {
97
100
  type: 'number',
98
101
  name: 'startYear',
99
102
  initial: new Date().getFullYear(),
100
103
  message: 'Start year for generated posts?'
101
- },
102
- {
104
+ }, {
103
105
  type: 'confirm',
104
106
  name: 'yearMode',
105
107
  initial: true,
@@ -155,6 +157,8 @@ for (let i = 1; i < numPosts; i++) {
155
157
  let response = await fetch(`https://baconipsum.com/api/?type=all-meat&paras=${getRandomInt(10)}&start-with-lorem=1`);
156
158
  let postContent = await response.json();
157
159
  log.debug(`Post content: ${postContent}`);
160
+ if (generatorInfo)
161
+ postContent.push(GENERATOR_CONTENT);
158
162
  var thePost = '---\n';
159
163
  thePost += YAML.stringify(postFm, { logLevel: 'silent' });
160
164
  thePost += '---\n\n';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-generate-posts",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Generates batches of Eleventy posts",
5
5
  "author": "John M. Wargo",
6
6
  "license": "MIT",
@@ -19,7 +19,8 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "test": "echo \"Error: no test specified\" && exit 1",
22
- "start": "tsc && node eleventy-generate-posts.js"
22
+ "start": "tsc && node eleventy-generate-posts.js",
23
+ "startg": "tsc && node eleventy-generate-posts.js -g"
23
24
  },
24
25
  "dependencies": {
25
26
  "boxen": "^7.0.2",
package/readme.md CHANGED
@@ -18,7 +18,7 @@ npm install -g eleventy-generate-posts
18
18
 
19
19
  This adds a `11ty-gp` command to the system.
20
20
 
21
- You don't have to install the package to use it; simply open a terminal window or command prompt to your Eleventy project folder and execute the command using `npx eleventy-generate-posts` and the command-line options described in the following section.
21
+ You don't have to install the package to use it; simply open a terminal window or command prompt to your Eleventy project folder and execute the command using `npx eleventy-generate-posts` and it will execute without being installed.
22
22
 
23
23
  ## Usage
24
24
 
@@ -38,8 +38,8 @@ The module will prompt you for all the required options:
38
38
  └─────────────────────────┘
39
39
  by John M. Wargo (https://johnwargo.com)
40
40
 
41
- √ Target folder for generated posts? ... posts
42
41
  √ Number of posts to generate? ... 10
42
+ √ Target folder for generated posts? ... posts
43
43
  √ Post tag? ... post
44
44
  √ Start year for generated posts? ... 2023
45
45
  √ Use year folder for posts? ... yes
@@ -69,8 +69,8 @@ Writing: D:\dev\node\11ty-generate-posts\posts\2023\splinter-ecology-computer-ne
69
69
 
70
70
  Configuration options are:
71
71
 
72
- * **Posts Folder:** Relative path pointing to the Eleventy project's posts folder; use `.` for the current folder.
73
72
  * **Number of Posts:** An integer value between 1 and 100 representing the number of posts generated.
73
+ * **Posts Folder:** Relative path pointing to the Eleventy project's posts folder; use `.` for the current folder.
74
74
  * **Post Tag:** The front matter `tag` property applied to the generated posts
75
75
  * **Start Year:** The starting year used for post date in the generated posts. The command uses the current date or the current date with the specified year (when provided) to for the post date for the first generated post. For subsequent post dates, the command randomly decrements the day.
76
76
  * **Use Year Folder:** specifies whether the module writes generated posts to the Posts folder (`N`) or into a separate folder for each year (`Y`).
@@ -79,6 +79,11 @@ Obviously if you generate enough posts to push into the previous year, the posts
79
79
 
80
80
  To enable debug mode, pass a `-d` flag on the command-line; in this mode, the module writes additional information to the console as it executes.
81
81
 
82
+ Add a reference to this module at the bottom of all generated posts using the `-g` command-line parameter. I added this feature primarily for my personal use so I can advertise the module when I use it. Here's an example of the added content:
83
+
84
+ > ***
85
+ > Post content generated by [Eleventy Generate Posts](https://www.npmjs.com/package/eleventy-generate-posts)
86
+
82
87
  ## Example Post
83
88
 
84
89
  A sample generated post looks like the following: