noblog 0.0.1-2.alpha

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Souvik Kar Mahapatra
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # noblog
2
+
3
+ This package aims to generate static content from notion.so and provide a plugable component/theme market for you bloggers.
4
+
5
+ the pattern would be like notablog (see reference), but more flexiable thanks to the mighty power of Astro
6
+
7
+ # Usage
8
+
9
+ ```
10
+ npm install -g noblog
11
+ noblog
12
+ ```
13
+
14
+ 1. \[OPTIONAL\] Duplicate this [database](https://www.notion.so/humbornjo/fa0faae85c504934a4a86cfa70302850?v=2abd1079ae134fbd8df2604765baa1df) and write blogs on it.
15
+
16
+ 2. Find a astro template, here is a shabby template I made: [nobloger](https://github.com/humbornjo/nobloger)
17
+
18
+ 3. set two env variables:
19
+
20
+ ```
21
+ NOBLOG_DATABASE_ID: your notion database id.
22
+ NOTION_API_SECRET: your notion api secret.
23
+ ```
24
+
25
+ 4. Run `noblog` and deploy your site.
26
+
27
+ By default, `noblog` saves all your post (the posts at the surface og your database) under `SAVE_PATH`.
28
+
29
+ The articles that are not directly posted on the database is saved under `SAVE_PATH/SUB_PATH`.
30
+
31
+ The default value of `SAVE_PATH` is `./src/pages/posts/`, `SUB_PATH` is `nob_children/`
32
+
33
+ So if you run `noblog` only, the file structure would be,
34
+
35
+ ```
36
+ project root
37
+ └──src
38
+ └── pages
39
+    └── posts
40
+       ├── blog_1.md
41
+       ├── blog_2.md
42
+       └── nob_children
43
+       ├── referenced_blog_1.md
44
+       ├── referenced_blog_2.md
45
+       ├── referenced_blog_3.md
46
+       ├── referenced_blog_4.md
47
+       └── referenced_blog_5.md
48
+ ```
49
+
50
+ Save dir could be altered by add args when running command,
51
+
52
+ ```
53
+ noblog <SAVE_PATH> <SUB_PATH>
54
+ ```
55
+
56
+ At this time, all the generated markdown is with Astro style, which means each file has a frontmatter like this,
57
+
58
+ ```
59
+ ---
60
+ layout: ../../layouts/MarkdownPostLayout.astro
61
+ title: "golang blog"
62
+ tags: ["lang", "go"]
63
+ pubDate: 2024-01-24
64
+ archived: false
65
+ description: "sometimes I hate, sometimes I love. <3"
66
+ ---
67
+ ```
68
+
69
+ Layout used is hard coded in the name of `./src/layouts/MarkdownPostLayout.astro`
70
+
71
+ In addition, any astro template that offer `./src/layouts/MarkdownPostLayout.astro` and use the default blog file structure (please refer to the code block above) is compatiable with `noblog`.
72
+
73
+ # Millstone
74
+
75
+ - \[2024.07.08\] fuck around
76
+ - \[2024.07.20\] generate github flavored markdown
77
+ - \[2024.09.04\] at least it worked
78
+
79
+ # Reference
80
+
81
+ I really appreciate their work and effort. I stealed and refactored some :)
82
+
83
+ - [notion api](https://developers.notion.com/reference/intro)
84
+ - [notion sdk](https://developers.notion.com/docs/getting-started)
85
+ - [notion-to-md](https://github.com/souvikinator/notion-to-md)
86
+ - [notablog](https://github.com/dragonman225/notablog)
87
+ - [astro-notion-blog](https://github.com/otoyo/astro-notion-blog)
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/cmds/generate.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ import { Noblog } from "../lib/nomd/nomd.js";
3
+ import { GetAllPosts } from "../lib/notion/client.js";
4
+ function help() {
5
+ console.log(`\n
6
+ Usage: noblog [SAVE_PATH] [SUB_PATH]
7
+
8
+ Example:
9
+ noblog
10
+ noblog src/pages/posts/ nob_children/
11
+
12
+ Available <option>:
13
+ -v Print more messages for debugging.\n`);
14
+ }
15
+ async function main() {
16
+ const argv = process.argv.slice(2);
17
+ if (argv.length > 2) {
18
+ console.error("Error: invallid arg.");
19
+ help();
20
+ }
21
+ const save_dir = argv[0] ?? "./src/pages/posts/";
22
+ const sub_dir = argv[1] ?? "nob_children/";
23
+ const pages = await GetAllPosts();
24
+ const nob = new Noblog(pages, save_dir, sub_dir);
25
+ nob.Collect(true);
26
+ }
27
+ main();
28
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/cmds/generate.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,SAAS,IAAI;IACX,OAAO,CAAC,GAAG,CAAC;;;;;;;;2CAQ6B,CAAC,CAAA;AAC5C,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;IACpC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACtC,IAAI,EAAE,CAAC;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,eAAe,CAAA;IAC1C,MAAM,KAAK,GAAG,MAAM,WAAW,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAEhD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AACnB,CAAC;AAED,IAAI,EAAE,CAAA"}