noblog 0.0.9 → 0.0.11
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/README.md +31 -21
- package/dist/cmds/generate.js +28 -0
- package/dist/cmds/generate.js.map +1 -0
- package/dist/generate.cjs +487 -41
- package/dist/generate.cjs.map +1 -1
- package/dist/generate.js +487 -41
- package/dist/generate.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/nomd/format.d.ts.map +1 -1
- package/dist/lib/nomd/format.js +111 -0
- package/dist/lib/nomd/format.js.map +1 -0
- package/dist/lib/nomd/nomd.d.ts +9 -3
- package/dist/lib/nomd/nomd.d.ts.map +1 -1
- package/dist/lib/nomd/nomd.js +489 -0
- package/dist/lib/nomd/nomd.js.map +1 -0
- package/dist/lib/notion/client.d.ts +12 -3
- package/dist/lib/notion/client.d.ts.map +1 -1
- package/dist/lib/notion/client.js +98 -0
- package/dist/lib/notion/client.js.map +1 -0
- package/dist/lib/notion/object.d.ts.map +1 -1
- package/dist/lib/notion/object.js +2 -0
- package/dist/lib/notion/object.js.map +1 -0
- package/dist/lib/notion/request.js +2 -0
- package/dist/lib/notion/request.js.map +1 -0
- package/package.json +45 -37
package/README.md
CHANGED
|
@@ -4,22 +4,31 @@ This package aims to generate static content from notion.so and provide a plugab
|
|
|
4
4
|
|
|
5
5
|
the pattern would be like notablog (see reference), but more flexiable thanks to the mighty power of Astro
|
|
6
6
|
|
|
7
|
-
# Usage
|
|
7
|
+
# Usage
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
npm install -g noblog
|
|
11
11
|
noblog
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
1. Duplicate this [database](https://www.notion.so/humbornjo/fa0faae85c504934a4a86cfa70302850?v=2abd1079ae134fbd8df2604765baa1df) and write blogs on it.
|
|
14
|
+
1. \[OPTIONAL\] Duplicate this [database](https://www.notion.so/humbornjo/fa0faae85c504934a4a86cfa70302850?v=2abd1079ae134fbd8df2604765baa1df) and write blogs on it.
|
|
15
|
+
|
|
15
16
|
2. Find a astro template, here is a shabby template I made: [nobloger](https://github.com/humbornjo/nobloger)
|
|
16
|
-
3. Run `noblog` and deploy your site.
|
|
17
17
|
|
|
18
|
-
|
|
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`.
|
|
19
28
|
|
|
20
29
|
The articles that are not directly posted on the database is saved under `SAVE_PATH/SUB_PATH`.
|
|
21
30
|
|
|
22
|
-
The default value of `SAVE_PATH` is `./src/pages/posts/`, `SUB_PATH` is `nob_children/`
|
|
31
|
+
The default value of `SAVE_PATH` is `./src/pages/posts/`, `SUB_PATH` is `nob_children/`
|
|
23
32
|
|
|
24
33
|
So if you run `noblog` only, the file structure would be,
|
|
25
34
|
|
|
@@ -51,27 +60,28 @@ At this time, all the generated markdown is with Astro style, which means each f
|
|
|
51
60
|
layout: ../../layouts/MarkdownPostLayout.astro
|
|
52
61
|
title: "golang blog"
|
|
53
62
|
tags: ["lang", "go"]
|
|
54
|
-
|
|
63
|
+
pubDate: 2024-01-24
|
|
55
64
|
archived: false
|
|
56
|
-
|
|
65
|
+
description: "sometimes I hate, sometimes I love. <3"
|
|
57
66
|
---
|
|
58
67
|
```
|
|
59
68
|
|
|
60
|
-
Layout used is hard coded in `./src/layouts/MarkdownPostLayout.astro`
|
|
69
|
+
Layout used is hard coded in the name of `./src/layouts/MarkdownPostLayout.astro`
|
|
61
70
|
|
|
62
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`.
|
|
63
72
|
|
|
64
|
-
|
|
65
73
|
# Millstone
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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,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"}
|