@noxion/core 0.0.1
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 +21 -0
- package/README.md +38 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +7 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +27 -0
- package/dist/config.js.map +1 -0
- package/dist/fetcher.d.ts +9 -0
- package/dist/fetcher.d.ts.map +1 -0
- package/dist/fetcher.js +189 -0
- package/dist/fetcher.js.map +1 -0
- package/dist/frontmatter.d.ts +6 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +75 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/image-downloader.d.ts +9 -0
- package/dist/image-downloader.d.ts.map +1 -0
- package/dist/image-downloader.js +95 -0
- package/dist/image-downloader.js.map +1 -0
- package/dist/image-mapper.d.ts +5 -0
- package/dist/image-mapper.d.ts.map +1 -0
- package/dist/image-mapper.js +38 -0
- package/dist/image-mapper.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-executor.d.ts +4 -0
- package/dist/plugin-executor.d.ts.map +1 -0
- package/dist/plugin-executor.js +43 -0
- package/dist/plugin-executor.js.map +1 -0
- package/dist/plugin-loader.d.ts +4 -0
- package/dist/plugin-loader.d.ts.map +1 -0
- package/dist/plugin-loader.js +46 -0
- package/dist/plugin-loader.js.map +1 -0
- package/dist/plugin.d.ts +80 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/analytics.d.ts +8 -0
- package/dist/plugins/analytics.d.ts.map +1 -0
- package/dist/plugins/analytics.js +57 -0
- package/dist/plugins/analytics.js.map +1 -0
- package/dist/plugins/comments.d.ts +23 -0
- package/dist/plugins/comments.d.ts.map +1 -0
- package/dist/plugins/comments.js +55 -0
- package/dist/plugins/comments.js.map +1 -0
- package/dist/plugins/index.d.ts +7 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/rss.d.ts +10 -0
- package/dist/plugins/rss.d.ts.map +1 -0
- package/dist/plugins/rss.js +55 -0
- package/dist/plugins/rss.js.map +1 -0
- package/dist/slug.d.ts +6 -0
- package/dist/slug.d.ts.map +1 -0
- package/dist/slug.js +34 -0
- package/dist/slug.js.map +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jiwon
|
|
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,38 @@
|
|
|
1
|
+
# @noxion/core
|
|
2
|
+
|
|
3
|
+
Core data fetching, config, and plugin system for [Noxion](https://github.com/jiwonme/noxion) — a Notion-powered blog builder.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Notion API client wrapper
|
|
8
|
+
- Blog post fetching and caching
|
|
9
|
+
- Frontmatter parsing from Notion code blocks
|
|
10
|
+
- Plugin system (analytics, RSS, comments)
|
|
11
|
+
- Image downloading and mapping utilities
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @noxion/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { defineConfig, fetchBlogPosts, createRSSPlugin } from "@noxion/core";
|
|
23
|
+
|
|
24
|
+
const config = defineConfig({
|
|
25
|
+
rootNotionPageId: process.env.NOTION_PAGE_ID!,
|
|
26
|
+
name: "My Blog",
|
|
27
|
+
domain: "myblog.com",
|
|
28
|
+
plugins: [createRSSPlugin({ feedPath: "/feed.xml" })],
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
See the [full documentation](https://github.com/jiwonme/noxion) for complete usage guides.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,SAAS,CAI/E"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAM1C,MAAM,UAAU,kBAAkB,CAAC,UAA+B,EAAE;IAClE,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;AACL,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAS/D,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAEzE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAkBjE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const DEFAULTS = {
|
|
2
|
+
language: "en",
|
|
3
|
+
defaultTheme: "system",
|
|
4
|
+
revalidate: 3600,
|
|
5
|
+
};
|
|
6
|
+
export function defineConfig(config) {
|
|
7
|
+
return config;
|
|
8
|
+
}
|
|
9
|
+
export function loadConfig(input) {
|
|
10
|
+
if (!input.rootNotionPageId) {
|
|
11
|
+
throw new Error("rootNotionPageId is required");
|
|
12
|
+
}
|
|
13
|
+
if (!input.name) {
|
|
14
|
+
throw new Error("name is required");
|
|
15
|
+
}
|
|
16
|
+
if (!input.domain) {
|
|
17
|
+
throw new Error("domain is required");
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
...DEFAULTS,
|
|
21
|
+
...input,
|
|
22
|
+
language: input.language ?? DEFAULTS.language,
|
|
23
|
+
defaultTheme: input.defaultTheme ?? DEFAULTS.defaultTheme,
|
|
24
|
+
revalidate: input.revalidate ?? DEFAULTS.revalidate,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GACZ;IACE,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,QAAQ;IACtB,UAAU,EAAE,IAAI;CACjB,CAAC;AAEJ,MAAM,UAAU,YAAY,CAAC,MAAyB;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAwB;IACjD,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAED,OAAO;QACL,GAAG,QAAQ;QACX,GAAG,KAAK;QACR,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ;QAC7C,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY;QACzD,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU;KACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NotionAPI } from "notion-client";
|
|
2
|
+
import type { ExtendedRecordMap } from "notion-types";
|
|
3
|
+
import type { BlogPost } from "./types";
|
|
4
|
+
export { createNotionClient } from "./client";
|
|
5
|
+
export declare function fetchPage(client: NotionAPI, pageId: string): Promise<ExtendedRecordMap>;
|
|
6
|
+
export declare function fetchBlogPosts(client: NotionAPI, databasePageId: string): Promise<BlogPost[]>;
|
|
7
|
+
export declare function fetchAllSlugs(client: NotionAPI, databasePageId: string): Promise<string[]>;
|
|
8
|
+
export declare function fetchPostBySlug(client: NotionAPI, databasePageId: string, slug: string): Promise<BlogPost | undefined>;
|
|
9
|
+
//# sourceMappingURL=fetcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../src/fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAkD,MAAM,cAAc,CAAC;AAEtG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAYxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAsB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE7F;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAGrB;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,SAAS,EACjB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAG/B"}
|
package/dist/fetcher.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { getTextContent, defaultMapImageUrl } from "notion-utils";
|
|
2
|
+
import { applyFrontmatter, parseKeyValuePairs } from "./frontmatter";
|
|
3
|
+
function unwrapValue(boxed) {
|
|
4
|
+
if (!boxed)
|
|
5
|
+
return undefined;
|
|
6
|
+
const val = boxed.value;
|
|
7
|
+
if (val && typeof val === "object" && "role" in val && "value" in val) {
|
|
8
|
+
return val.value;
|
|
9
|
+
}
|
|
10
|
+
return val;
|
|
11
|
+
}
|
|
12
|
+
export { createNotionClient } from "./client";
|
|
13
|
+
export async function fetchPage(client, pageId) {
|
|
14
|
+
return client.getPage(pageId);
|
|
15
|
+
}
|
|
16
|
+
export async function fetchBlogPosts(client, databasePageId) {
|
|
17
|
+
const recordMap = await client.getPage(databasePageId);
|
|
18
|
+
return extractPostsFromRecordMap(recordMap, databasePageId);
|
|
19
|
+
}
|
|
20
|
+
export async function fetchAllSlugs(client, databasePageId) {
|
|
21
|
+
const posts = await fetchBlogPosts(client, databasePageId);
|
|
22
|
+
return posts.map((p) => p.slug);
|
|
23
|
+
}
|
|
24
|
+
export async function fetchPostBySlug(client, databasePageId, slug) {
|
|
25
|
+
const posts = await fetchBlogPosts(client, databasePageId);
|
|
26
|
+
return posts.find((p) => p.slug === slug);
|
|
27
|
+
}
|
|
28
|
+
function extractPostsFromRecordMap(recordMap, _databasePageId) {
|
|
29
|
+
const collectionBox = Object.values(recordMap.collection)[0];
|
|
30
|
+
const collection = unwrapValue(collectionBox);
|
|
31
|
+
if (!collection)
|
|
32
|
+
return [];
|
|
33
|
+
const schema = collection.schema;
|
|
34
|
+
if (!schema)
|
|
35
|
+
return [];
|
|
36
|
+
const collectionQuery = recordMap.collection_query;
|
|
37
|
+
const collectionId = Object.keys(recordMap.collection)[0];
|
|
38
|
+
if (!collectionId)
|
|
39
|
+
return [];
|
|
40
|
+
const queryResults = collectionQuery?.[collectionId];
|
|
41
|
+
const blockIds = collectAllBlockIds(queryResults);
|
|
42
|
+
const schemaMap = buildSchemaMap(schema);
|
|
43
|
+
const posts = [];
|
|
44
|
+
for (const blockId of blockIds) {
|
|
45
|
+
const block = unwrapValue(recordMap.block[blockId]);
|
|
46
|
+
if (!block || block.type !== "page")
|
|
47
|
+
continue;
|
|
48
|
+
const properties = block.properties;
|
|
49
|
+
if (!properties)
|
|
50
|
+
continue;
|
|
51
|
+
let post = extractPost(blockId, properties, schemaMap, block);
|
|
52
|
+
const frontmatter = extractInlineFrontmatter(recordMap, block);
|
|
53
|
+
if (frontmatter) {
|
|
54
|
+
post = applyFrontmatter(post, frontmatter);
|
|
55
|
+
}
|
|
56
|
+
if (post.published) {
|
|
57
|
+
posts.push(post);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
posts.sort((a, b) => {
|
|
61
|
+
const dateA = new Date(a.date).getTime();
|
|
62
|
+
const dateB = new Date(b.date).getTime();
|
|
63
|
+
return dateB - dateA;
|
|
64
|
+
});
|
|
65
|
+
return posts;
|
|
66
|
+
}
|
|
67
|
+
function collectAllBlockIds(queryResults) {
|
|
68
|
+
if (!queryResults)
|
|
69
|
+
return [];
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
for (const view of Object.values(queryResults)) {
|
|
72
|
+
const ids = view?.blockIds ?? view?.collection_group_results?.blockIds ?? [];
|
|
73
|
+
for (const id of ids)
|
|
74
|
+
seen.add(id);
|
|
75
|
+
}
|
|
76
|
+
return [...seen];
|
|
77
|
+
}
|
|
78
|
+
function buildSchemaMap(schema) {
|
|
79
|
+
const map = {
|
|
80
|
+
titleKey: null,
|
|
81
|
+
slugKey: null,
|
|
82
|
+
dateKey: null,
|
|
83
|
+
tagsKey: null,
|
|
84
|
+
categoryKey: null,
|
|
85
|
+
publishedKey: null,
|
|
86
|
+
coverKey: null,
|
|
87
|
+
descriptionKey: null,
|
|
88
|
+
authorKey: null,
|
|
89
|
+
};
|
|
90
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
91
|
+
const name = value.name?.toLowerCase();
|
|
92
|
+
if (value.type === "title")
|
|
93
|
+
map.titleKey = key;
|
|
94
|
+
else if (name === "slug")
|
|
95
|
+
map.slugKey = key;
|
|
96
|
+
else if (name === "tags")
|
|
97
|
+
map.tagsKey = key;
|
|
98
|
+
else if (name === "category")
|
|
99
|
+
map.categoryKey = key;
|
|
100
|
+
else if (name === "cover")
|
|
101
|
+
map.coverKey = key;
|
|
102
|
+
else if (name === "description")
|
|
103
|
+
map.descriptionKey = key;
|
|
104
|
+
else if (name === "author")
|
|
105
|
+
map.authorKey = key;
|
|
106
|
+
else if ((name === "public" || name === "published") && value.type === "checkbox")
|
|
107
|
+
map.publishedKey = key;
|
|
108
|
+
else if ((name === "date" || name === "published") && (value.type === "date" || value.type === "last_edited_time"))
|
|
109
|
+
map.dateKey = key;
|
|
110
|
+
}
|
|
111
|
+
return map;
|
|
112
|
+
}
|
|
113
|
+
function extractPost(id, properties, schema, block) {
|
|
114
|
+
const title = schema.titleKey ? getTextContent(properties[schema.titleKey]) : "";
|
|
115
|
+
const rawSlug = schema.slugKey ? getTextContent(properties[schema.slugKey]) : "";
|
|
116
|
+
const slug = rawSlug || id;
|
|
117
|
+
const dateRaw = schema.dateKey ? getTextContent(properties[schema.dateKey]) : "";
|
|
118
|
+
const date = parseDateValue(dateRaw, properties[schema.dateKey ?? ""]);
|
|
119
|
+
const tagsRaw = schema.tagsKey ? getTextContent(properties[schema.tagsKey]) : "";
|
|
120
|
+
const tags = tagsRaw ? tagsRaw.split(",").map((t) => t.trim()).filter(Boolean) : [];
|
|
121
|
+
const category = schema.categoryKey
|
|
122
|
+
? getTextContent(properties[schema.categoryKey])
|
|
123
|
+
: undefined;
|
|
124
|
+
const description = schema.descriptionKey
|
|
125
|
+
? getTextContent(properties[schema.descriptionKey])
|
|
126
|
+
: undefined;
|
|
127
|
+
const author = schema.authorKey
|
|
128
|
+
? getTextContent(properties[schema.authorKey])
|
|
129
|
+
: undefined;
|
|
130
|
+
const publishedRaw = schema.publishedKey
|
|
131
|
+
? getTextContent(properties[schema.publishedKey])
|
|
132
|
+
: "";
|
|
133
|
+
const published = publishedRaw === "Yes" || publishedRaw === "yes" || publishedRaw === "true";
|
|
134
|
+
const rawCover = block.format?.page_cover;
|
|
135
|
+
const coverImage = rawCover
|
|
136
|
+
? defaultMapImageUrl(rawCover, block)
|
|
137
|
+
: undefined;
|
|
138
|
+
const lastEditedTime = block.last_edited_time
|
|
139
|
+
? new Date(block.last_edited_time).toISOString()
|
|
140
|
+
: new Date().toISOString();
|
|
141
|
+
return {
|
|
142
|
+
id,
|
|
143
|
+
title,
|
|
144
|
+
slug,
|
|
145
|
+
date,
|
|
146
|
+
tags,
|
|
147
|
+
category: category || undefined,
|
|
148
|
+
description: description || undefined,
|
|
149
|
+
author: author || undefined,
|
|
150
|
+
coverImage,
|
|
151
|
+
published,
|
|
152
|
+
lastEditedTime,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function extractInlineFrontmatter(recordMap, pageBlock) {
|
|
156
|
+
const childIds = pageBlock.content;
|
|
157
|
+
if (!childIds || childIds.length === 0)
|
|
158
|
+
return null;
|
|
159
|
+
const firstChild = unwrapValue(recordMap.block[childIds[0]]);
|
|
160
|
+
if (!firstChild || firstChild.type !== "code")
|
|
161
|
+
return null;
|
|
162
|
+
const props = firstChild.properties;
|
|
163
|
+
if (!props?.title)
|
|
164
|
+
return null;
|
|
165
|
+
const codeText = getTextContent(props.title);
|
|
166
|
+
if (!codeText.trim())
|
|
167
|
+
return null;
|
|
168
|
+
return parseKeyValuePairs(codeText);
|
|
169
|
+
}
|
|
170
|
+
function parseDateValue(textContent, rawProperty) {
|
|
171
|
+
if (rawProperty) {
|
|
172
|
+
for (const segment of rawProperty) {
|
|
173
|
+
if (Array.isArray(segment) && segment.length >= 2) {
|
|
174
|
+
const annotations = segment[1];
|
|
175
|
+
if (Array.isArray(annotations)) {
|
|
176
|
+
for (const ann of annotations) {
|
|
177
|
+
if (Array.isArray(ann) && ann[0] === "d" && ann[1]?.start_date) {
|
|
178
|
+
return ann[1].start_date;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (textContent)
|
|
186
|
+
return textContent;
|
|
187
|
+
return "";
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=fetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetcher.js","sourceRoot":"","sources":["../src/fetcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAErE,SAAS,WAAW,CAAI,KAA2E;IACjG,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC;IACxB,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,EAAE,CAAC;QACtE,OAAQ,GAAkC,CAAC,KAAK,CAAC;IACnD,CAAC;IACD,OAAO,GAAQ,CAAC;AAClB,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAiB,EAAE,MAAc;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,cAAsB;IAEtB,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACvD,OAAO,yBAAyB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAiB,EACjB,cAAsB;IAEtB,MAAM,KAAK,GAAG,MAAM,cAAc,CA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AAE,CAAC;wBAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;4BAC/D,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;wBAC3B,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,WAAW;QAAE,OAAO,WAAW,CAAC;IACpC,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExtendedRecordMap } from "notion-types";
|
|
2
|
+
import type { BlogPost } from "./types";
|
|
3
|
+
export declare function parseFrontmatter(recordMap: ExtendedRecordMap, pageId: string): Record<string, string> | null;
|
|
4
|
+
export declare function parseKeyValuePairs(text: string): Record<string, string>;
|
|
5
|
+
export declare function applyFrontmatter(post: BlogPost, frontmatter: Record<string, string>): BlogPost;
|
|
6
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAS,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUxC,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAmB/B;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsBvE;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,QAAQ,CAoCV"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { getTextContent } from "notion-utils";
|
|
2
|
+
function unwrapBlock(box) {
|
|
3
|
+
const b = box;
|
|
4
|
+
if (!b?.value)
|
|
5
|
+
return undefined;
|
|
6
|
+
return b.value;
|
|
7
|
+
}
|
|
8
|
+
export function parseFrontmatter(recordMap, pageId) {
|
|
9
|
+
const pageBox = recordMap.block[pageId];
|
|
10
|
+
const pageBlock = unwrapBlock(pageBox);
|
|
11
|
+
if (!pageBlock)
|
|
12
|
+
return null;
|
|
13
|
+
const childIds = pageBlock.content;
|
|
14
|
+
if (!childIds || childIds.length === 0)
|
|
15
|
+
return null;
|
|
16
|
+
const firstChildId = childIds[0];
|
|
17
|
+
const firstBlock = unwrapBlock(recordMap.block[firstChildId]);
|
|
18
|
+
if (!firstBlock || firstBlock.type !== "code")
|
|
19
|
+
return null;
|
|
20
|
+
const properties = firstBlock.properties;
|
|
21
|
+
if (!properties?.title)
|
|
22
|
+
return null;
|
|
23
|
+
const codeText = getTextContent(properties.title);
|
|
24
|
+
if (!codeText.trim())
|
|
25
|
+
return null;
|
|
26
|
+
return parseKeyValuePairs(codeText);
|
|
27
|
+
}
|
|
28
|
+
export function parseKeyValuePairs(text) {
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const line of text.split("\n")) {
|
|
31
|
+
const trimmed = line.trim();
|
|
32
|
+
if (!trimmed || trimmed.startsWith("#") || !trimmed.includes(":"))
|
|
33
|
+
continue;
|
|
34
|
+
const colonIndex = trimmed.indexOf(":");
|
|
35
|
+
const key = trimmed.slice(0, colonIndex).trim();
|
|
36
|
+
let value = trimmed.slice(colonIndex + 1).trim();
|
|
37
|
+
if (!key)
|
|
38
|
+
continue;
|
|
39
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
40
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
41
|
+
value = value.slice(1, -1);
|
|
42
|
+
}
|
|
43
|
+
result[key] = value;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
export function applyFrontmatter(post, frontmatter) {
|
|
48
|
+
const updated = { ...post, frontmatter };
|
|
49
|
+
if (frontmatter.title) {
|
|
50
|
+
updated.title = frontmatter.title;
|
|
51
|
+
}
|
|
52
|
+
if (frontmatter.description) {
|
|
53
|
+
updated.description = frontmatter.description;
|
|
54
|
+
}
|
|
55
|
+
if (frontmatter.cleanUrl) {
|
|
56
|
+
updated.slug = frontmatter.cleanUrl.replace(/^\//, "");
|
|
57
|
+
}
|
|
58
|
+
if (frontmatter.slug) {
|
|
59
|
+
updated.slug = frontmatter.slug.replace(/^\//, "");
|
|
60
|
+
}
|
|
61
|
+
if (frontmatter.date) {
|
|
62
|
+
updated.date = frontmatter.date;
|
|
63
|
+
}
|
|
64
|
+
if (frontmatter.category) {
|
|
65
|
+
updated.category = frontmatter.category;
|
|
66
|
+
}
|
|
67
|
+
if (frontmatter.tags) {
|
|
68
|
+
updated.tags = frontmatter.tags.split(",").map((t) => t.trim()).filter(Boolean);
|
|
69
|
+
}
|
|
70
|
+
if (frontmatter.coverImage || frontmatter.cover) {
|
|
71
|
+
updated.coverImage = frontmatter.coverImage ?? frontmatter.cover;
|
|
72
|
+
}
|
|
73
|
+
return updated;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAK9C,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,CAAC,GAAG,GAA2B,CAAC;IACtC,IAAI,CAAC,CAAC,EAAE,KAAK;QAAE,OAAO,SAAS,CAAC;IAChC,OAAO,CAAC,CAAC,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,SAA4B,EAC5B,MAAc;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CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;IAC1C,CAAC;IAED,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClF,CAAC;IAED,IAAI,WAAW,CAAC,UAAU,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;QAChD,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,IAAI,WAAW,CAAC,KAAK,CAAC;IACnE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtendedRecordMap } from "notion-types";
|
|
2
|
+
export interface DownloadImagesOptions {
|
|
3
|
+
concurrency?: number;
|
|
4
|
+
onProgress?: (done: number, total: number) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function extractImageUrls(recordMap: ExtendedRecordMap): string[];
|
|
7
|
+
export declare function generateImageFilename(url: string): string;
|
|
8
|
+
export declare function downloadImages(recordMap: ExtendedRecordMap, outputDir: string, options?: DownloadImagesOptions): Promise<Record<string, string>>;
|
|
9
|
+
//# sourceMappingURL=image-downloader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-downloader.d.ts","sourceRoot":"","sources":["../src/image-downloader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAS,MAAM,cAAc,CAAC;AAK7D,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAUD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,EAAE,CA8BvE;AAoBD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA4CjC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
function unwrapBlock(box) {
|
|
5
|
+
const b = box;
|
|
6
|
+
if (!b?.value)
|
|
7
|
+
return undefined;
|
|
8
|
+
return b.value;
|
|
9
|
+
}
|
|
10
|
+
export function extractImageUrls(recordMap) {
|
|
11
|
+
const urls = new Set();
|
|
12
|
+
for (const blockId of Object.keys(recordMap.block)) {
|
|
13
|
+
const block = unwrapBlock(recordMap.block[blockId]);
|
|
14
|
+
if (!block)
|
|
15
|
+
continue;
|
|
16
|
+
if (block.type === "image") {
|
|
17
|
+
const signedUrl = recordMap.signed_urls?.[block.id];
|
|
18
|
+
const sourceUrl = block.properties
|
|
19
|
+
?.source?.[0]?.[0];
|
|
20
|
+
const url = signedUrl || sourceUrl;
|
|
21
|
+
if (url && isAbsoluteUrl(url)) {
|
|
22
|
+
urls.add(url);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const format = block.format;
|
|
26
|
+
if (format) {
|
|
27
|
+
for (const key of ["page_cover", "bookmark_cover", "bookmark_icon"]) {
|
|
28
|
+
const val = format[key];
|
|
29
|
+
if (val && isAbsoluteUrl(val)) {
|
|
30
|
+
urls.add(val);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return [...urls];
|
|
36
|
+
}
|
|
37
|
+
function isAbsoluteUrl(str) {
|
|
38
|
+
return str.startsWith("https://") || str.startsWith("http://");
|
|
39
|
+
}
|
|
40
|
+
function extractExtension(url) {
|
|
41
|
+
try {
|
|
42
|
+
const pathname = new URL(url).pathname;
|
|
43
|
+
const lastDot = pathname.lastIndexOf(".");
|
|
44
|
+
if (lastDot !== -1) {
|
|
45
|
+
const ext = pathname.slice(lastDot + 1).toLowerCase();
|
|
46
|
+
if (/^[a-z0-9]{2,5}$/.test(ext))
|
|
47
|
+
return ext;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
/* expected for malformed URLs */
|
|
52
|
+
}
|
|
53
|
+
return "png";
|
|
54
|
+
}
|
|
55
|
+
export function generateImageFilename(url) {
|
|
56
|
+
const hash = createHash("sha256").update(url).digest("hex").slice(0, 16);
|
|
57
|
+
const ext = extractExtension(url);
|
|
58
|
+
return `${hash}.${ext}`;
|
|
59
|
+
}
|
|
60
|
+
export async function downloadImages(recordMap, outputDir, options) {
|
|
61
|
+
const urls = extractImageUrls(recordMap);
|
|
62
|
+
if (urls.length === 0)
|
|
63
|
+
return {};
|
|
64
|
+
const concurrency = options?.concurrency ?? 5;
|
|
65
|
+
const onProgress = options?.onProgress;
|
|
66
|
+
const imagesDir = join(outputDir, "images");
|
|
67
|
+
await mkdir(imagesDir, { recursive: true });
|
|
68
|
+
const urlMap = {};
|
|
69
|
+
let done = 0;
|
|
70
|
+
const chunks = [];
|
|
71
|
+
for (let i = 0; i < urls.length; i += concurrency) {
|
|
72
|
+
chunks.push(urls.slice(i, i + concurrency));
|
|
73
|
+
}
|
|
74
|
+
for (const chunk of chunks) {
|
|
75
|
+
const results = await Promise.allSettled(chunk.map(async (url) => {
|
|
76
|
+
const filename = generateImageFilename(url);
|
|
77
|
+
const filePath = join(imagesDir, filename);
|
|
78
|
+
const response = await fetch(url);
|
|
79
|
+
if (!response.ok)
|
|
80
|
+
return null;
|
|
81
|
+
const buffer = await response.arrayBuffer();
|
|
82
|
+
await writeFile(filePath, Buffer.from(buffer));
|
|
83
|
+
return { url, localPath: filePath };
|
|
84
|
+
}));
|
|
85
|
+
for (const result of results) {
|
|
86
|
+
done++;
|
|
87
|
+
if (result.status === "fulfilled" && result.value) {
|
|
88
|
+
urlMap[result.value.url] = result.value.localPath;
|
|
89
|
+
}
|
|
90
|
+
onProgress?.(done, urls.length);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return urlMap;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=image-downloader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-downloader.js","sourceRoot":"","sources":["../src/image-downloader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,CAAC,GAAG,GAA2B,CAAC;IACtC,IAAI,CAAC,CAAC,EAAE,KAAK;QAAE,OAAO,SAAS,CAAC;IAChC,OAAO,CAAC,CAAC,KAAc,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,SAA4B;IAC3D,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CA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AAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-mapper.d.ts","sourceRoot":"","sources":["../src/image-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAS,MAAM,cAAc,CAAC;AAG7D,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAWrC,wBAAgB,SAAS,CACvB,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,MAAM,GACb,iBAAiB,CAgCnB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function cloneRecordMap(recordMap) {
|
|
2
|
+
return JSON.parse(JSON.stringify(recordMap));
|
|
3
|
+
}
|
|
4
|
+
function replaceUrl(url, urlMap) {
|
|
5
|
+
if (!url)
|
|
6
|
+
return url;
|
|
7
|
+
return urlMap[url] ?? url;
|
|
8
|
+
}
|
|
9
|
+
export function mapImages(recordMap, urlMap) {
|
|
10
|
+
const mapped = cloneRecordMap(recordMap);
|
|
11
|
+
for (const blockId of Object.keys(mapped.block)) {
|
|
12
|
+
const box = mapped.block[blockId];
|
|
13
|
+
if (!box?.value)
|
|
14
|
+
continue;
|
|
15
|
+
const block = box.value;
|
|
16
|
+
if (block.type === "image") {
|
|
17
|
+
const props = block.properties;
|
|
18
|
+
if (props?.source?.[0]?.[0]) {
|
|
19
|
+
props.source[0][0] = replaceUrl(props.source[0][0], urlMap);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const format = block.format;
|
|
23
|
+
if (format) {
|
|
24
|
+
for (const key of ["page_cover", "bookmark_cover", "bookmark_icon"]) {
|
|
25
|
+
if (format[key]) {
|
|
26
|
+
format[key] = replaceUrl(format[key], urlMap);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (mapped.signed_urls) {
|
|
32
|
+
for (const [blockId, url] of Object.entries(mapped.signed_urls)) {
|
|
33
|
+
mapped.signed_urls[blockId] = replaceUrl(url, urlMap);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return mapped;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=image-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-mapper.js","sourceRoot":"","sources":["../src/image-mapper.ts"],"names":[],"mappings":"AAKA,SAAS,cAAc,CAAC,SAA4B;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,UAAU,CAAC,GAAuB,EAAE,MAAc;IACzD,IAAI,CAAC,GAAG;QAAE,OAAO,GAAG,CAAC;IACrB,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,SAA4B,EAC5B,MAAc;IAEd,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAEzC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAoC,CAAC;QACrE,IAAI,CAAC,GAAG,EAAE,KAAK;YAAE,SAAS;QAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QAExB,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,UAAoD,CAAC;YACzE,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAE,CAAC;YAC/D,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAA4C,CAAC;QAClE,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,gBAAgB,EAAE,eAAe,CAAU,EAAE,CAAC;gBAC7E,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChB,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAE,CAAC;gBACjD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YAChE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,MAAM,CAAE,CAAC;QACzD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { defineConfig, loadConfig } from "./config";
|
|
2
|
+
export { createNotionClient } from "./client";
|
|
3
|
+
export { fetchBlogPosts, fetchPage, fetchAllSlugs, fetchPostBySlug } from "./fetcher";
|
|
4
|
+
export { generateSlug, parseNotionPageId, buildPageUrl, resolveSlug } from "./slug";
|
|
5
|
+
export { parseFrontmatter, parseKeyValuePairs, applyFrontmatter } from "./frontmatter";
|
|
6
|
+
export { extractImageUrls, generateImageFilename, downloadImages } from "./image-downloader";
|
|
7
|
+
export type { DownloadImagesOptions } from "./image-downloader";
|
|
8
|
+
export { mapImages } from "./image-mapper";
|
|
9
|
+
export { definePlugin, loadPlugins } from "./plugin-loader";
|
|
10
|
+
export { executeHook, executeTransformHook } from "./plugin-executor";
|
|
11
|
+
export type { NoxionPlugin, PluginFactory, PluginModule, PluginConfigEntry, PluginActions, AllContent, HeadTag, SitemapEntry, RouteInfo, NoxionMetadata, } from "./plugin";
|
|
12
|
+
export type { NoxionConfig, NoxionConfigInput, BlogPost, NoxionPageData, NoxionLayout, ThemeMode, PluginConfig, NoxionThemeConfig, ComponentOverrides, ExtendedRecordMap, } from "./types";
|
|
13
|
+
export type { NotionClientOptions } from "./client";
|
|
14
|
+
export { createAnalyticsPlugin, createRSSPlugin, generateRSSXml, createCommentsPlugin, } from "./plugins/index";
|
|
15
|
+
export type { AnalyticsPluginOptions, RSSPluginOptions, CommentsPluginOptions, GiscusConfig, UtterancesConfig, DisqusConfig, } from "./plugins/index";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC7F,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACtE,YAA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