@centrolabs/ngx-blogdown 1.0.0 → 1.2.0

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.
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readdirSync, readFileSync, writeFileSync } from 'fs';
4
+ import { join } from 'path';
5
+
6
+ const flags = { '--postsDir': null, '--out': null };
7
+ process.argv.forEach((val, idx, args) => {
8
+ if (val in flags) {
9
+ if (idx + 1 < args.length) {
10
+ flags[val] = args[idx + 1];
11
+ }
12
+ }
13
+ });
14
+
15
+ let abort = false;
16
+ Object.entries(flags).forEach(([flag, value]) => {
17
+ if (!value) {
18
+ abort = true;
19
+ console.error(`Please provide the ${flag} flag`);
20
+ }
21
+ });
22
+
23
+ if (abort) process.exit(1);
24
+
25
+ const postsDir = flags['--postsDir'];
26
+ const outputFile = flags['--out'];
27
+
28
+ const files = readdirSync(postsDir).filter((f) => f.endsWith('.md'));
29
+
30
+ const posts = files.map((filename) => {
31
+ const raw = readFileSync(join(postsDir, filename), 'utf-8');
32
+ const separatorMatch = raw.match(/^-{3,}$/m);
33
+ const headerEnd = separatorMatch ? separatorMatch.index : -1;
34
+ const header = headerEnd !== -1 ? raw.slice(0, headerEnd) : '';
35
+
36
+ const meta = {};
37
+ for (const line of header.trim().split('\n')) {
38
+ const colonIndex = line.indexOf(':');
39
+ if (colonIndex !== -1) {
40
+ const key = line.slice(0, colonIndex).trim();
41
+ const value = line.slice(colonIndex + 1).trim();
42
+ meta[key] = value;
43
+ }
44
+ }
45
+
46
+ const slug = filename.replace(/\.md$/, '').replace(/\s+/g, '-').toLowerCase();
47
+
48
+ return {
49
+ slug,
50
+ filename,
51
+ title: meta.title || filename.replace(/\.md$/, ''),
52
+ date: meta.date || '',
53
+ cover: meta.cover || '',
54
+ tagline: meta.tagline || '',
55
+ author: meta.author || null,
56
+ };
57
+ });
58
+
59
+ // Sort by date descending
60
+ posts.sort((a, b) => b.date.localeCompare(a.date));
61
+
62
+ writeFileSync(outputFile, JSON.stringify(posts, null, 2));
63
+ console.log(`Generated blog index with ${posts.length} post(s).`);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@centrolabs/ngx-blogdown",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "A lightweight Angular library for building markdown-powered blogs. You handle the layout, we handle the pipeline.",
5
5
  "peerDependencies": {
6
- "@angular/common": "^20.3.0",
7
- "@angular/core": "^20.3.0",
6
+ "@angular/common": ">=20.3.0",
7
+ "@angular/core": ">=20.3.0",
8
8
  "marked": "^17.0.0"
9
9
  },
10
10
  "dependencies": {