astroplugin-logseq 1.1.1 → 1.3.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.
- package/README.md +7 -0
- package/dist/index.cjs +63 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +64 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,11 +9,15 @@ This plugin creates a synchronization bridge between a local Logseq graph and As
|
|
|
9
9
|
|
|
10
10
|
It operates by polling the Logseq HTTP API for pages containing specific tags and writing them as Markdown files to defined directories within an Astro project. This allows a Logseq graph to function as a content source for static site generation without manual export steps.
|
|
11
11
|
|
|
12
|
+

|
|
13
|
+
|
|
12
14
|
## Functionality
|
|
13
15
|
* **API Polling:** Connects to the local Logseq HTTP API to retrieve page content.
|
|
14
16
|
* **Selective Sync:** Filters pages based on user-defined tags (e.g., `blog`, `notes`) and maps them to specific target directories.
|
|
15
17
|
* **Block Preservation:** Maintains the hierarchy of Logseq blocks, rendering them as nested lists in the output Markdown.
|
|
16
18
|
* **Change Detection:** Compares fetched content against existing files on disk to minimize unnecessary write operations.
|
|
19
|
+
* **Handles references:** Strips away `[[]]` unless they are in a code block.
|
|
20
|
+
* **Set custom property for published date:** Customise the Logseq property used to set the published date in Astro.
|
|
17
21
|
|
|
18
22
|
## Installation
|
|
19
23
|
npm install astroplugin-logseq
|
|
@@ -39,6 +43,9 @@ export default defineConfig({
|
|
|
39
43
|
// Required: The authorization token generated in Logseq
|
|
40
44
|
token: 'YOUR_SECRET_LOGSEQ_TOKEN',
|
|
41
45
|
|
|
46
|
+
// Required: The Logseq property used for the page you want to publish
|
|
47
|
+
dateRef: 'publish-date',
|
|
48
|
+
|
|
42
49
|
// Required: mapping tags to destination directories
|
|
43
50
|
targets: [
|
|
44
51
|
{
|
package/dist/index.cjs
CHANGED
|
@@ -49,12 +49,26 @@ var hasContentChanged = async (path2, newContent) => {
|
|
|
49
49
|
// src/utils/process-tag-group.ts
|
|
50
50
|
var import_date_fns = require("date-fns");
|
|
51
51
|
|
|
52
|
+
// src/api/get-date-prop-ident.ts
|
|
53
|
+
var getDatePropPage = async (api, dateRef, logger) => {
|
|
54
|
+
try {
|
|
55
|
+
const datePropPage = await api.post({
|
|
56
|
+
method: "logseq.Editor.getPage",
|
|
57
|
+
args: [dateRef]
|
|
58
|
+
}).json();
|
|
59
|
+
const datePropPageIdent = datePropPage.ident;
|
|
60
|
+
return datePropPageIdent;
|
|
61
|
+
} catch (e) {
|
|
62
|
+
logger.info(`Unable to get page for date reference: ${String(e)}`);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
52
66
|
// src/api/get-page-blocks-tree.ts
|
|
53
|
-
var getPageBlocksTree = async (api,
|
|
67
|
+
var getPageBlocksTree = async (api, page, logger) => {
|
|
54
68
|
try {
|
|
55
69
|
return await api.post({
|
|
56
70
|
method: "logseq.Editor.getPageBlocksTree",
|
|
57
|
-
args: [
|
|
71
|
+
args: [page.title.toLowerCase()]
|
|
58
72
|
}).json();
|
|
59
73
|
} catch (e) {
|
|
60
74
|
logger.info(`Unable to get page blocks tree: ${String(e)}`);
|
|
@@ -62,19 +76,20 @@ var getPageBlocksTree = async (api, item, logger) => {
|
|
|
62
76
|
};
|
|
63
77
|
|
|
64
78
|
// src/api/get-raw-response.ts
|
|
65
|
-
var getRawResponse = async (api, tag, logger) => {
|
|
79
|
+
var getRawResponse = async (api, datePropPageIdent, tag, logger) => {
|
|
66
80
|
const query = `
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{:block/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
[:find (pull ?p
|
|
82
|
+
[:block/name
|
|
83
|
+
:block/full-title
|
|
84
|
+
:block/created-at
|
|
85
|
+
:block/updated-at
|
|
86
|
+
:block/title
|
|
87
|
+
${datePropPageIdent && `{${datePropPageIdent} [:block/journal-day]}`}
|
|
88
|
+
{:block/_parent [:block/uuid]}])
|
|
89
|
+
:where
|
|
90
|
+
[?p :block/name]
|
|
91
|
+
[?p :block/tags ?t]
|
|
92
|
+
[?t :block/name "${tag}"]]`;
|
|
78
93
|
try {
|
|
79
94
|
return await api.post({
|
|
80
95
|
method: "logseq.DB.datascriptQuery",
|
|
@@ -88,22 +103,30 @@ var getRawResponse = async (api, tag, logger) => {
|
|
|
88
103
|
};
|
|
89
104
|
|
|
90
105
|
// src/utils/process-tag-group.ts
|
|
91
|
-
var processTagGroup = async (api, target, logger) => {
|
|
106
|
+
var processTagGroup = async (api, dateRef, target, logger) => {
|
|
92
107
|
const { tag, directory } = target;
|
|
93
|
-
const rawResponse = await getRawResponse(api, tag, logger);
|
|
94
|
-
if (!rawResponse || rawResponse.length === 0) return;
|
|
95
108
|
const mappedResponse = [];
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
const datePropPageIdent = await getDatePropPage(api, dateRef, logger);
|
|
110
|
+
const rawResponse = await getRawResponse(api, datePropPageIdent, tag, logger);
|
|
111
|
+
if (!rawResponse || rawResponse.length === 0) return;
|
|
112
|
+
for (const page of rawResponse.flat()) {
|
|
113
|
+
const pbt = await getPageBlocksTree(api, page, logger);
|
|
98
114
|
if (!pbt) continue;
|
|
99
115
|
mappedResponse.push({
|
|
100
|
-
createdAt: (0, import_date_fns.format)(
|
|
101
|
-
updatedAt: (0, import_date_fns.format)(
|
|
102
|
-
pageTitle:
|
|
103
|
-
content: recursivelyGetContent(pbt)
|
|
116
|
+
createdAt: (0, import_date_fns.format)(page["created-at"], "yyyy-MM-dd"),
|
|
117
|
+
updatedAt: (0, import_date_fns.format)(page["updated-at"], "yyyy-MM-dd"),
|
|
118
|
+
pageTitle: page.title,
|
|
119
|
+
content: recursivelyGetContent(pbt),
|
|
120
|
+
...datePropPageIdent && {
|
|
121
|
+
date: (0, import_date_fns.parse)(
|
|
122
|
+
String(page[datePropPageIdent]["journal-day"]),
|
|
123
|
+
"yyyyMMdd",
|
|
124
|
+
/* @__PURE__ */ new Date()
|
|
125
|
+
)
|
|
126
|
+
}
|
|
104
127
|
});
|
|
128
|
+
await writeToMd(directory, mappedResponse, logger);
|
|
105
129
|
}
|
|
106
|
-
await writeToMd(directory, mappedResponse, logger);
|
|
107
130
|
};
|
|
108
131
|
|
|
109
132
|
// src/utils/recursively-get-content.ts
|
|
@@ -111,7 +134,16 @@ var recursivelyGetContent = (contentBlocks, depth = 0) => {
|
|
|
111
134
|
let content = "";
|
|
112
135
|
const indent = " ".repeat(depth);
|
|
113
136
|
for (const block of contentBlocks) {
|
|
114
|
-
const text = block.
|
|
137
|
+
const text = (block.fullTitle ?? "").replace(
|
|
138
|
+
/(`[^`]+`)|\[\[(.*?)\]\]/g,
|
|
139
|
+
(_match, code, linkContent) => {
|
|
140
|
+
if (code) return code;
|
|
141
|
+
const isCodeDisplay = block[":logseq.property.node/display-type"] === "code";
|
|
142
|
+
return isCodeDisplay ? `\`\`\`
|
|
143
|
+
[[${linkContent}]]
|
|
144
|
+
\`\`\`` : linkContent;
|
|
145
|
+
}
|
|
146
|
+
);
|
|
115
147
|
if (depth === 0) {
|
|
116
148
|
content += `
|
|
117
149
|
|
|
@@ -145,7 +177,7 @@ var writeToMd = async (directory, mappedResponse, logger) => {
|
|
|
145
177
|
const filePath = import_node_path.default.join(targetDir, `${cleanSlug}.md`);
|
|
146
178
|
const fileContent = `---
|
|
147
179
|
title: ${page.pageTitle}
|
|
148
|
-
date: ${page.
|
|
180
|
+
date: ${page.date}
|
|
149
181
|
---
|
|
150
182
|
${page.content}`;
|
|
151
183
|
const contentToSave = fileContent.trim();
|
|
@@ -164,6 +196,7 @@ function logseqIntegration(options) {
|
|
|
164
196
|
const {
|
|
165
197
|
token,
|
|
166
198
|
targets,
|
|
199
|
+
dateRef,
|
|
167
200
|
apiUrl = "http://127.0.0.1:12315/api",
|
|
168
201
|
pollingInterval = 1e3
|
|
169
202
|
} = options;
|
|
@@ -171,7 +204,7 @@ function logseqIntegration(options) {
|
|
|
171
204
|
name: "astro-logseq-publish",
|
|
172
205
|
hooks: {
|
|
173
206
|
"astro:server:setup": ({ logger }) => {
|
|
174
|
-
logger.info(
|
|
207
|
+
logger.info(`\u{1F680} Logseq Poller Started (Every ${pollingInterval}ms)`);
|
|
175
208
|
const api = (0, import_wretch.default)().url(apiUrl).headers({
|
|
176
209
|
"Content-Type": "application/json",
|
|
177
210
|
Authorization: `Bearer ${token}`
|
|
@@ -179,7 +212,9 @@ function logseqIntegration(options) {
|
|
|
179
212
|
setInterval(async () => {
|
|
180
213
|
try {
|
|
181
214
|
await Promise.all(
|
|
182
|
-
targets.map(
|
|
215
|
+
targets.map(
|
|
216
|
+
(target) => processTagGroup(api, dateRef, target, logger)
|
|
217
|
+
)
|
|
183
218
|
);
|
|
184
219
|
} catch (e) {
|
|
185
220
|
logger.error(e.message || String(e));
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/has-content-changed.ts","../src/utils/process-tag-group.ts","../src/api/get-page-blocks-tree.ts","../src/api/get-raw-response.ts","../src/utils/recursively-get-content.ts","../src/utils/write-to-md.ts","../src/utils/get-clean-slug.ts"],"sourcesContent":["import { AstroIntegration } from 'astro'\nimport wretch from 'wretch'\n\nimport { LogseqIntegrationOptions } from './types'\nimport { processTagGroup } from './utils'\n\nexport default function logseqIntegration(\n options: LogseqIntegrationOptions,\n): AstroIntegration {\n const {\n token,\n targets,\n apiUrl = 'http://127.0.0.1:12315/api',\n pollingInterval = 1000,\n } = options\n\n return {\n name: 'astro-logseq-publish',\n hooks: {\n 'astro:server:setup': ({ logger }) => {\n logger.info('🚀 Logseq Poller Started (Every 3s)')\n\n const api = wretch()\n .url(apiUrl)\n .headers({\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n })\n\n setInterval(async () => {\n try {\n await Promise.all(\n targets.map((target) => processTagGroup(api, target, logger)),\n )\n } catch (e: any) {\n logger.error(e.message || String(e))\n }\n }, pollingInterval)\n },\n 'astro:build:setup': async ({ logger }) => {\n logger.info('Building from Logseq...')\n },\n },\n }\n}\n","import fs from \"node:fs/promises\";\n\nexport const hasContentChanged = async (path: string, newContent: string) => {\n try {\n const currentContent = await fs.readFile(path, \"utf-8\");\n return currentContent !== newContent;\n } catch {\n return true;\n }\n};\n","import { format } from 'date-fns'\nimport { Wretch } from 'wretch/types'\n\nimport { getPageBlocksTree, getRawResponse } from '../api'\nimport { MappedResponse, TagTarget } from '../types'\nimport { recursivelyGetContent, writeToMd } from '.'\n\nexport const processTagGroup = async (\n api: Wretch,\n target: TagTarget,\n logger: any,\n) => {\n const { tag, directory } = target\n\n const rawResponse = await getRawResponse(api, tag, logger)\n if (!rawResponse || rawResponse.length === 0) return\n\n const mappedResponse: MappedResponse[] = []\n\n for (const item of rawResponse.flat()) {\n const pbt = await getPageBlocksTree(api, item, logger)\n if (!pbt) continue\n\n mappedResponse.push({\n createdAt: format(item['created-at'], 'yyyy-MM-dd'),\n updatedAt: format(item['updated-at'], 'yyyy-MM-dd'),\n pageTitle: item.title,\n content: recursivelyGetContent(pbt),\n })\n }\n\n await writeToMd(directory, mappedResponse, logger)\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { Wretch } from 'wretch/types'\n\nimport { ContentBlock, LogseqResponse } from '../types'\n\nexport const getPageBlocksTree = async (\n api: Wretch,\n item: LogseqResponse,\n logger: AstroIntegrationLogger,\n) => {\n try {\n return await api\n .post({\n method: 'logseq.Editor.getPageBlocksTree',\n args: [item.title.toLowerCase()],\n })\n .json<ContentBlock[]>()\n } catch (e) {\n logger.info(`Unable to get page blocks tree: ${String(e)}`)\n }\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { Wretch } from 'wretch/types'\n\nimport { LogseqResponse } from '../types'\n\nexport const getRawResponse = async (\n api: Wretch,\n tag: string,\n logger: AstroIntegrationLogger,\n) => {\n const query = `\n [:find (pull ?p\n [:block/name\n :block/full-title\n :block/created-at\n :block/updated-at\n :block/title\n {:block/_parent ...}])\n :where\n [?p :block/name]\n [?p :block/tags ?t]\n [?t :block/name \"${tag}\"]]`\n\n try {\n return (\n (await api\n .post({\n method: 'logseq.DB.datascriptQuery',\n args: [query],\n })\n .json<LogseqResponse[][]>()) ?? []\n )\n } catch (e) {\n logger.info(\n `Unable to query Logseq. Check if API server is running. ${String(e)}`,\n )\n }\n}\n","import { ContentBlock } from \"../types\";\n\nexport const recursivelyGetContent = (\n contentBlocks: ContentBlock[],\n depth = 0,\n) => {\n let content = \"\";\n const indent = \" \".repeat(depth);\n for (const block of contentBlocks) {\n const text = block.title || \"\";\n if (depth === 0) {\n content += `\\n\\n${text}`;\n } else {\n content += `\\n${indent}- ${text}`;\n }\n if (block.children && block.children.length > 0) {\n content += recursivelyGetContent(block.children, depth + 1);\n }\n }\n return content;\n};\n","import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { AstroIntegrationLogger } from 'astro'\n\nimport { MappedResponse } from '../types'\nimport { hasContentChanged } from '.'\nimport { getCleanSlug } from './get-clean-slug'\n\nexport const writeToMd = async (\n directory: string,\n mappedResponse: MappedResponse[],\n logger: AstroIntegrationLogger,\n) => {\n const targetDir = path.resolve(process.cwd(), directory)\n\n try {\n await fs.mkdir(targetDir, { recursive: true })\n await Promise.all(\n mappedResponse.map(async (page) => {\n const cleanSlug = getCleanSlug(page)\n const filePath = path.join(targetDir, `${cleanSlug}.md`)\n const fileContent = `---\ntitle: ${page.pageTitle}\ndate: ${page.createdAt}\n---\n${page.content}`\n const contentToSave = fileContent.trim()\n if (await hasContentChanged(filePath, contentToSave)) {\n await fs.writeFile(filePath, contentToSave, 'utf-8')\n }\n }),\n )\n } catch (e) {\n logger.info(`Unable to create MD files: ${String(e)}`)\n }\n}\n","import { MappedResponse } from '../types'\n\nexport const getCleanSlug = (page: MappedResponse) =>\n page.pageTitle\n .toLowerC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,cAAc;AAAA,SACnB,KAAK,SAAS;AAAA,QACf,KAAK,SAAS;AAAA;AAAA,EAEpB,KAAK,OAAO;AACN,cAAM,gBAAgB,YAAY,KAAK;AACvC,YAAI,MAAM,kBAAkB,UAAU,aAAa,GAAG;AACpD,gBAAM,iBAAAC,QAAG,UAAU,UAAU,eAAe,OAAO;AAAA,QACrD;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,SAAS,GAAG;AACV,WAAO,KAAK,8BAA8B,OAAO,CAAC,CAAC,EAAE;AAAA,EACvD;AACF;;;AN9Be,SAAR,kBACL,SACkB;AAClB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,kBAAkB;AAAA,EACpB,IAAI;AAEJ,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,MACL,sBAAsB,CAAC,EAAE,OAAO,MAAM;AACpC,eAAO,KAAK,4CAAqC;AAEjD,cAAM,UAAM,cAAAC,SAAO,EAChB,IAAI,MAAM,EACV,QAAQ;AAAA,UACP,gBAAgB;AAAA,UAChB,eAAe,UAAU,KAAK;AAAA,QAChC,CAAC;AAEH,oBAAY,YAAY;AACtB,cAAI;AACF,kBAAM,QAAQ;AAAA,cACZ,QAAQ,IAAI,CAAC,WAAW,gBAAgB,KAAK,QAAQ,MAAM,CAAC;AAAA,YAC9D;AAAA,UACF,SAAS,GAAQ;AACf,mBAAO,MAAM,EAAE,WAAW,OAAO,CAAC,CAAC;AAAA,UACrC;AAAA,QACF,GAAG,eAAe;AAAA,MACpB;AAAA,MACA,qBAAqB,OAAO,EAAE,OAAO,MAAM;AACzC,eAAO,KAAK,yBAAyB;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACF;","names":["path","fs","import_promises","path","fs","wretch"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/has-content-changed.ts","../src/utils/process-tag-group.ts","../src/api/get-date-prop-ident.ts","../src/api/get-page-blocks-tree.ts","../src/api/get-raw-response.ts","../src/utils/recursively-get-content.ts","../src/utils/write-to-md.ts","../src/utils/get-clean-slug.ts"],"sourcesContent":["import { AstroIntegration } from 'astro'\nimport wretch from 'wretch'\n\nimport { LogseqIntegrationOptions } from './types'\nimport { processTagGroup } from './utils'\n\nexport default function logseqIntegration(\n options: LogseqIntegrationOptions,\n): AstroIntegration {\n const {\n token,\n targets,\n dateRef,\n apiUrl = 'http://127.0.0.1:12315/api',\n pollingInterval = 1000,\n } = options\n\n return {\n name: 'astro-logseq-publish',\n hooks: {\n 'astro:server:setup': ({ logger }) => {\n logger.info(`🚀 Logseq Poller Started (Every ${pollingInterval}ms)`)\n\n const api = wretch()\n .url(apiUrl)\n .headers({\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n })\n\n setInterval(async () => {\n try {\n await Promise.all(\n targets.map((target) =>\n processTagGroup(api, dateRef, target, logger),\n ),\n )\n } catch (e: any) {\n logger.error(e.message || String(e))\n }\n }, pollingInterval)\n },\n 'astro:build:setup': async ({ logger }) => {\n logger.info('Building from Logseq...')\n },\n },\n }\n}\n","import fs from \"node:fs/promises\";\n\nexport const hasContentChanged = async (path: string, newContent: string) => {\n try {\n const currentContent = await fs.readFile(path, \"utf-8\");\n return currentContent !== newContent;\n } catch {\n return true;\n }\n};\n","import { AstroIntegrationLogger } from 'astro'\nimport { format, parse } from 'date-fns'\nimport { Wretch } from 'wretch/types'\n\nimport { getDatePropPage, getPageBlocksTree, getRawResponse } from '../api'\nimport { MappedResponse, TagTarget } from '../types'\nimport { recursivelyGetContent, writeToMd } from '.'\n\nexport const processTagGroup = async (\n api: Wretch,\n dateRef: string,\n target: TagTarget,\n logger: AstroIntegrationLogger,\n) => {\n const { tag, directory } = target\n const mappedResponse: MappedResponse[] = []\n\n const datePropPageIdent = await getDatePropPage(api, dateRef, logger)\n\n const rawResponse = await getRawResponse(api, datePropPageIdent, tag, logger)\n if (!rawResponse || rawResponse.length === 0) return\n\n for (const page of rawResponse.flat()) {\n const pbt = await getPageBlocksTree(api, page, logger)\n if (!pbt) continue\n\n mappedResponse.push({\n createdAt: format(page['created-at'], 'yyyy-MM-dd'),\n updatedAt: format(page['updated-at'], 'yyyy-MM-dd'),\n pageTitle: page.title,\n content: recursivelyGetContent(pbt),\n ...(datePropPageIdent && {\n date: parse(\n String(page[datePropPageIdent!]['journal-day']),\n 'yyyyMMdd',\n new Date(),\n ),\n }),\n })\n await writeToMd(directory, mappedResponse, logger)\n }\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { LogseqPageResponse } from 'src/types'\nimport { Wretch } from 'wretch/types'\n\nexport const getDatePropPage = async (\n api: Wretch,\n dateRef: string,\n logger: AstroIntegrationLogger,\n) => {\n try {\n const datePropPage = await api\n .post({\n method: 'logseq.Editor.getPage',\n args: [dateRef],\n })\n .json<LogseqPageResponse>()\n const datePropPageIdent = datePropPage.ident\n return datePropPageIdent\n } catch (e) {\n logger.info(`Unable to get page for date reference: ${String(e)}`)\n }\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { Wretch } from 'wretch/types'\n\nimport { ContentBlock, LogseqPageResponse } from '../types'\n\nexport const getPageBlocksTree = async (\n api: Wretch,\n page: LogseqPageResponse,\n logger: AstroIntegrationLogger,\n) => {\n try {\n return await api\n .post({\n method: 'logseq.Editor.getPageBlocksTree',\n args: [page.title.toLowerCase()],\n })\n .json<ContentBlock[]>()\n } catch (e) {\n logger.info(`Unable to get page blocks tree: ${String(e)}`)\n }\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { Wretch } from 'wretch/types'\n\nimport { LogseqPageResponse } from '../types'\n\nexport const getRawResponse = async (\n api: Wretch,\n datePropPageIdent: string | undefined,\n tag: string,\n logger: AstroIntegrationLogger,\n) => {\n const query = `\n [:find (pull ?p\n [:block/name\n :block/full-title\n :block/created-at\n :block/updated-at\n :block/title\n ${datePropPageIdent && `{${datePropPageIdent} [:block/journal-day]}`}\n {:block/_parent [:block/uuid]}])\n :where\n [?p :block/name]\n [?p :block/tags ?t]\n [?t :block/name \"${tag}\"]]`\n\n try {\n return (\n (await api\n .post({\n method: 'logseq.DB.datascriptQuery',\n args: [query],\n })\n .json<LogseqPageResponse[][]>()) ?? []\n )\n } catch (e) {\n logger.info(\n `Unable to query Logseq. Check if API server is running. ${String(e)}`,\n )\n }\n}\n","import { ContentBlock } from '../types'\n\nexport const recursivelyGetContent = (\n contentBlocks: ContentBlock[],\n depth = 0,\n) => {\n let content = ''\n const indent = ' '.repeat(depth)\n for (const block of contentBlocks) {\n const text = (block.fullTitle ?? '').replace(\n /(`[^`]+`)|\\[\\[(.*?)\\]\\]/g,\n (_match, code, linkContent) => {\n if (code) return code\n const isCodeDisplay =\n block[':logseq.property.node/display-type'] === 'code'\n return isCodeDisplay\n ? `\\`\\`\\`\\n[[${linkContent}]]\\n\\`\\`\\``\n : linkContent\n },\n )\n if (depth === 0) {\n content += `\\n\\n${text}`\n } else {\n content += `\\n${indent}- ${text}`\n }\n if (block.children && block.children.length > 0) {\n content += recursivelyGetContent(block.children, depth + 1)\n }\n }\n return content\n}\n","import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { AstroIntegrationLogger } from 'astro'\n\nimport { MappedResponse } from '../types'\nimport { hasContentChanged } from '.'\nimport { getCleanSlug } from './get-clean-slug'\n\nexport const writeToMd = async (\n directory: string,\n mappedResponse: MappedResponse[],\n logger: AstroIntegrationLogger,\n) => {\n const targetDir = path.resolve(process.cwd(), directory)\n\n try {\n await fs.mkdir(targetDir, { recursive: true })\n await Promise.all(\n mappedResponse.map(async (page) => {\n const cleanSlug = getCleanSlug(page)\n const filePath = path.join(targetDir, `${cleanSlug}.md`)\n const fileContent = `---\ntitle: ${page.pageTitle}\ndate: ${page.date}\n---\n${page.content}`\n const contentToSave = fileContent.trim()\n if (await hasContentChanged(filePath, contentToSave)) {\n await fs.writeFile(filePath, contentToSave, 'utf-8')\n }\n }),\n )\n } catch (e) {\n logger.info(`Unable to create MD files: ${String(e)}`)\n }\n}\n","import { MappedResponse } from '../types'\n\nexport const getCleanSlug = (page: MappedResponse) =>\n page.pageTitle\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/(^-|-$)/g, '')\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAmB;;;ACDnB,sBAAe;AAER,IAAM,oBAAoB,OAAOA,OAAc,eAAuB;AAC3E,MAAI;AACF,UAAM,iBAAiB,MAAM,gBAAAC,QAAG,SAASD,OAAM,OAAO;AACtD,WAAO,mBAAmB;AAAA,EAC5B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;ACRA,sBAA8B;;;ACGvB,IAAM,kBAAkB,OAC7B,KACA,SACA,WACG;AACH,MAAI;AACF,UAAM,eAAe,MAAM,IACxB,KAAK;AAAA,MACJ,QAAQ;AAAA,MACR,MAAM,CAAC,OAAO;AAAA,IAChB,CAAC,EACA,KAAyB;AAC5B,UAAM,oBAAoB,aAAa;AACvC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO,KAAK,0CAA0C,OAAO,CAAC,CAAC,EAAE;AAAA,EACnE;AACF;;;AChBO,IAAM,oBAAoB,OAC/B,KACA,MACA,WACG;AACH,MAAI;AACF,WAAO,MAAM,IACV,KAAK;AAAA,MACJ,QAAQ;AAAA,MACR,MAAM,CAAC,KAAK,MAAM,YAAY,CAAC;AAAA,IACjC,CAAC,EACA,KAAqB;AAAA,EAC1B,SAAS,GAAG;AACV,WAAO,KAAK,mCAAmC,OAAO,CAAC,CAAC,EAAE;AAAA,EAC5D;AACF;;;ACfO,IAAM,iBAAiB,OAC5B,KACA,mBACA,KACA,WACG;AACH,QAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAOU,qBAAqB,IAAI,iBAAiB,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,mCAKzD,GAAG;AAEpC,MAAI;AACF,WACG,MAAM,IACJ,KAAK;AAAA,MACJ,QAAQ;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IACA,SAAS;AAAA,IACT,kBAAkB;AAAA,EACpB,IAAI;AAEJ,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,MACL,sBAAsB,CAAC,EAAE,OAAO,MAAM;AACpC,eAAO,KAAK,0CAAmC,eAAe,KAAK;AAEnE,cAAM,UAAM,cAAAC,SAAO,EAChB,IAAI,MAAM,EACV,QAAQ;AAAA,UACP,gBAAgB;AAAA,UAChB,eAAe,UAAU,KAAK;AAAA,QAChC,CAAC;AAEH,oBAAY,YAAY;AACtB,cAAI;AACF,kBAAM,QAAQ;AAAA,cACZ,QAAQ;AAAA,gBAAI,CAAC,WACX,gBAAgB,KAAK,SAAS,QAAQ,MAAM;AAAA,cAC9C;AAAA,YACF;AAAA,UACF,SAAS,GAAQ;AACf,mBAAO,MAAM,EAAE,WAAW,OAAO,CAAC,CAAC;AAAA,UACrC;AAAA,QACF,GAAG,eAAe;AAAA,MACpB;AAAA,MACA,qBAAqB,OAAO,EAAE,OAAO,MAAM;AACzC,eAAO,KAAK,yBAAyB;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACF;","names":["path","fs","import_promises","path","fs","wretch"]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -13,14 +13,28 @@ var hasContentChanged = async (path2, newContent) => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// src/utils/process-tag-group.ts
|
|
16
|
-
import { format } from "date-fns";
|
|
16
|
+
import { format, parse } from "date-fns";
|
|
17
|
+
|
|
18
|
+
// src/api/get-date-prop-ident.ts
|
|
19
|
+
var getDatePropPage = async (api, dateRef, logger) => {
|
|
20
|
+
try {
|
|
21
|
+
const datePropPage = await api.post({
|
|
22
|
+
method: "logseq.Editor.getPage",
|
|
23
|
+
args: [dateRef]
|
|
24
|
+
}).json();
|
|
25
|
+
const datePropPageIdent = datePropPage.ident;
|
|
26
|
+
return datePropPageIdent;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
logger.info(`Unable to get page for date reference: ${String(e)}`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
17
31
|
|
|
18
32
|
// src/api/get-page-blocks-tree.ts
|
|
19
|
-
var getPageBlocksTree = async (api,
|
|
33
|
+
var getPageBlocksTree = async (api, page, logger) => {
|
|
20
34
|
try {
|
|
21
35
|
return await api.post({
|
|
22
36
|
method: "logseq.Editor.getPageBlocksTree",
|
|
23
|
-
args: [
|
|
37
|
+
args: [page.title.toLowerCase()]
|
|
24
38
|
}).json();
|
|
25
39
|
} catch (e) {
|
|
26
40
|
logger.info(`Unable to get page blocks tree: ${String(e)}`);
|
|
@@ -28,19 +42,20 @@ var getPageBlocksTree = async (api, item, logger) => {
|
|
|
28
42
|
};
|
|
29
43
|
|
|
30
44
|
// src/api/get-raw-response.ts
|
|
31
|
-
var getRawResponse = async (api, tag, logger) => {
|
|
45
|
+
var getRawResponse = async (api, datePropPageIdent, tag, logger) => {
|
|
32
46
|
const query = `
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{:block/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
[:find (pull ?p
|
|
48
|
+
[:block/name
|
|
49
|
+
:block/full-title
|
|
50
|
+
:block/created-at
|
|
51
|
+
:block/updated-at
|
|
52
|
+
:block/title
|
|
53
|
+
${datePropPageIdent && `{${datePropPageIdent} [:block/journal-day]}`}
|
|
54
|
+
{:block/_parent [:block/uuid]}])
|
|
55
|
+
:where
|
|
56
|
+
[?p :block/name]
|
|
57
|
+
[?p :block/tags ?t]
|
|
58
|
+
[?t :block/name "${tag}"]]`;
|
|
44
59
|
try {
|
|
45
60
|
return await api.post({
|
|
46
61
|
method: "logseq.DB.datascriptQuery",
|
|
@@ -54,22 +69,30 @@ var getRawResponse = async (api, tag, logger) => {
|
|
|
54
69
|
};
|
|
55
70
|
|
|
56
71
|
// src/utils/process-tag-group.ts
|
|
57
|
-
var processTagGroup = async (api, target, logger) => {
|
|
72
|
+
var processTagGroup = async (api, dateRef, target, logger) => {
|
|
58
73
|
const { tag, directory } = target;
|
|
59
|
-
const rawResponse = await getRawResponse(api, tag, logger);
|
|
60
|
-
if (!rawResponse || rawResponse.length === 0) return;
|
|
61
74
|
const mappedResponse = [];
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
const datePropPageIdent = await getDatePropPage(api, dateRef, logger);
|
|
76
|
+
const rawResponse = await getRawResponse(api, datePropPageIdent, tag, logger);
|
|
77
|
+
if (!rawResponse || rawResponse.length === 0) return;
|
|
78
|
+
for (const page of rawResponse.flat()) {
|
|
79
|
+
const pbt = await getPageBlocksTree(api, page, logger);
|
|
64
80
|
if (!pbt) continue;
|
|
65
81
|
mappedResponse.push({
|
|
66
|
-
createdAt: format(
|
|
67
|
-
updatedAt: format(
|
|
68
|
-
pageTitle:
|
|
69
|
-
content: recursivelyGetContent(pbt)
|
|
82
|
+
createdAt: format(page["created-at"], "yyyy-MM-dd"),
|
|
83
|
+
updatedAt: format(page["updated-at"], "yyyy-MM-dd"),
|
|
84
|
+
pageTitle: page.title,
|
|
85
|
+
content: recursivelyGetContent(pbt),
|
|
86
|
+
...datePropPageIdent && {
|
|
87
|
+
date: parse(
|
|
88
|
+
String(page[datePropPageIdent]["journal-day"]),
|
|
89
|
+
"yyyyMMdd",
|
|
90
|
+
/* @__PURE__ */ new Date()
|
|
91
|
+
)
|
|
92
|
+
}
|
|
70
93
|
});
|
|
94
|
+
await writeToMd(directory, mappedResponse, logger);
|
|
71
95
|
}
|
|
72
|
-
await writeToMd(directory, mappedResponse, logger);
|
|
73
96
|
};
|
|
74
97
|
|
|
75
98
|
// src/utils/recursively-get-content.ts
|
|
@@ -77,7 +100,16 @@ var recursivelyGetContent = (contentBlocks, depth = 0) => {
|
|
|
77
100
|
let content = "";
|
|
78
101
|
const indent = " ".repeat(depth);
|
|
79
102
|
for (const block of contentBlocks) {
|
|
80
|
-
const text = block.
|
|
103
|
+
const text = (block.fullTitle ?? "").replace(
|
|
104
|
+
/(`[^`]+`)|\[\[(.*?)\]\]/g,
|
|
105
|
+
(_match, code, linkContent) => {
|
|
106
|
+
if (code) return code;
|
|
107
|
+
const isCodeDisplay = block[":logseq.property.node/display-type"] === "code";
|
|
108
|
+
return isCodeDisplay ? `\`\`\`
|
|
109
|
+
[[${linkContent}]]
|
|
110
|
+
\`\`\`` : linkContent;
|
|
111
|
+
}
|
|
112
|
+
);
|
|
81
113
|
if (depth === 0) {
|
|
82
114
|
content += `
|
|
83
115
|
|
|
@@ -111,7 +143,7 @@ var writeToMd = async (directory, mappedResponse, logger) => {
|
|
|
111
143
|
const filePath = path.join(targetDir, `${cleanSlug}.md`);
|
|
112
144
|
const fileContent = `---
|
|
113
145
|
title: ${page.pageTitle}
|
|
114
|
-
date: ${page.
|
|
146
|
+
date: ${page.date}
|
|
115
147
|
---
|
|
116
148
|
${page.content}`;
|
|
117
149
|
const contentToSave = fileContent.trim();
|
|
@@ -130,6 +162,7 @@ function logseqIntegration(options) {
|
|
|
130
162
|
const {
|
|
131
163
|
token,
|
|
132
164
|
targets,
|
|
165
|
+
dateRef,
|
|
133
166
|
apiUrl = "http://127.0.0.1:12315/api",
|
|
134
167
|
pollingInterval = 1e3
|
|
135
168
|
} = options;
|
|
@@ -137,7 +170,7 @@ function logseqIntegration(options) {
|
|
|
137
170
|
name: "astro-logseq-publish",
|
|
138
171
|
hooks: {
|
|
139
172
|
"astro:server:setup": ({ logger }) => {
|
|
140
|
-
logger.info(
|
|
173
|
+
logger.info(`\u{1F680} Logseq Poller Started (Every ${pollingInterval}ms)`);
|
|
141
174
|
const api = wretch().url(apiUrl).headers({
|
|
142
175
|
"Content-Type": "application/json",
|
|
143
176
|
Authorization: `Bearer ${token}`
|
|
@@ -145,7 +178,9 @@ function logseqIntegration(options) {
|
|
|
145
178
|
setInterval(async () => {
|
|
146
179
|
try {
|
|
147
180
|
await Promise.all(
|
|
148
|
-
targets.map(
|
|
181
|
+
targets.map(
|
|
182
|
+
(target) => processTagGroup(api, dateRef, target, logger)
|
|
183
|
+
)
|
|
149
184
|
);
|
|
150
185
|
} catch (e) {
|
|
151
186
|
logger.error(e.message || String(e));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/has-content-changed.ts","../src/utils/process-tag-group.ts","../src/api/get-page-blocks-tree.ts","../src/api/get-raw-response.ts","../src/utils/recursively-get-content.ts","../src/utils/write-to-md.ts","../src/utils/get-clean-slug.ts"],"sourcesContent":["import { AstroIntegration } from 'astro'\nimport wretch from 'wretch'\n\nimport { LogseqIntegrationOptions } from './types'\nimport { processTagGroup } from './utils'\n\nexport default function logseqIntegration(\n options: LogseqIntegrationOptions,\n): AstroIntegration {\n const {\n token,\n targets,\n apiUrl = 'http://127.0.0.1:12315/api',\n pollingInterval = 1000,\n } = options\n\n return {\n name: 'astro-logseq-publish',\n hooks: {\n 'astro:server:setup': ({ logger }) => {\n logger.info('🚀 Logseq Poller Started (Every 3s)')\n\n const api = wretch()\n .url(apiUrl)\n .headers({\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n })\n\n setInterval(async () => {\n try {\n await Promise.all(\n targets.map((target) => processTagGroup(api, target, logger)),\n )\n } catch (e: any) {\n logger.error(e.message || String(e))\n }\n }, pollingInterval)\n },\n 'astro:build:setup': async ({ logger }) => {\n logger.info('Building from Logseq...')\n },\n },\n }\n}\n","import fs from \"node:fs/promises\";\n\nexport const hasContentChanged = async (path: string, newContent: string) => {\n try {\n const currentContent = await fs.readFile(path, \"utf-8\");\n return currentContent !== newContent;\n } catch {\n return true;\n }\n};\n","import { format } from 'date-fns'\nimport { Wretch } from 'wretch/types'\n\nimport { getPageBlocksTree, getRawResponse } from '../api'\nimport { MappedResponse, TagTarget } from '../types'\nimport { recursivelyGetContent, writeToMd } from '.'\n\nexport const processTagGroup = async (\n api: Wretch,\n target: TagTarget,\n logger: any,\n) => {\n const { tag, directory } = target\n\n const rawResponse = await getRawResponse(api, tag, logger)\n if (!rawResponse || rawResponse.length === 0) return\n\n const mappedResponse: MappedResponse[] = []\n\n for (const item of rawResponse.flat()) {\n const pbt = await getPageBlocksTree(api, item, logger)\n if (!pbt) continue\n\n mappedResponse.push({\n createdAt: format(item['created-at'], 'yyyy-MM-dd'),\n updatedAt: format(item['updated-at'], 'yyyy-MM-dd'),\n pageTitle: item.title,\n content: recursivelyGetContent(pbt),\n })\n }\n\n await writeToMd(directory, mappedResponse, logger)\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { Wretch } from 'wretch/types'\n\nimport { ContentBlock, LogseqResponse } from '../types'\n\nexport const getPageBlocksTree = async (\n api: Wretch,\n item: LogseqResponse,\n logger: AstroIntegrationLogger,\n) => {\n try {\n return await api\n .post({\n method: 'logseq.Editor.getPageBlocksTree',\n args: [item.title.toLowerCase()],\n })\n .json<ContentBlock[]>()\n } catch (e) {\n logger.info(`Unable to get page blocks tree: ${String(e)}`)\n }\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { Wretch } from 'wretch/types'\n\nimport { LogseqResponse } from '../types'\n\nexport const getRawResponse = async (\n api: Wretch,\n tag: string,\n logger: AstroIntegrationLogger,\n) => {\n const query = `\n [:find (pull ?p\n [:block/name\n :block/full-title\n :block/created-at\n :block/updated-at\n :block/title\n {:block/_parent ...}])\n :where\n [?p :block/name]\n [?p :block/tags ?t]\n [?t :block/name \"${tag}\"]]`\n\n try {\n return (\n (await api\n .post({\n method: 'logseq.DB.datascriptQuery',\n args: [query],\n })\n .json<LogseqResponse[][]>()) ?? []\n )\n } catch (e) {\n logger.info(\n `Unable to query Logseq. Check if API server is running. ${String(e)}`,\n )\n }\n}\n","import { ContentBlock } from \"../types\";\n\nexport const recursivelyGetContent = (\n contentBlocks: ContentBlock[],\n depth = 0,\n) => {\n let content = \"\";\n const indent = \" \".repeat(depth);\n for (const block of contentBlocks) {\n const text = block.title || \"\";\n if (depth === 0) {\n content += `\\n\\n${text}`;\n } else {\n content += `\\n${indent}- ${text}`;\n }\n if (block.children && block.children.length > 0) {\n content += recursivelyGetContent(block.children, depth + 1);\n }\n }\n return content;\n};\n","import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { AstroIntegrationLogger } from 'astro'\n\nimport { MappedResponse } from '../types'\nimport { hasContentChanged } from '.'\nimport { getCleanSlug } from './get-clean-slug'\n\nexport const writeToMd = async (\n directory: string,\n mappedResponse: MappedResponse[],\n logger: AstroIntegrationLogger,\n) => {\n const targetDir = path.resolve(process.cwd(), directory)\n\n try {\n await fs.mkdir(targetDir, { recursive: true })\n await Promise.all(\n mappedResponse.map(async (page) => {\n const cleanSlug = getCleanSlug(page)\n const filePath = path.join(targetDir, `${cleanSlug}.md`)\n const fileContent = `---\ntitle: ${page.pageTitle}\ndate: ${page.createdAt}\n---\n${page.content}`\n const contentToSave = fileContent.trim()\n if (await hasContentChanged(filePath, contentToSave)) {\n await fs.writeFile(filePath, contentToSave, 'utf-8')\n }\n }),\n )\n } catch (e) {\n logger.info(`Unable to create MD files: ${String(e)}`)\n }\n}\n","import { MappedResponse } from '../types'\n\nexport const getCleanSlug = (page: MappedResponse) =>\n page.pageTitle\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/(^-|-$)/g, '')\n"],"mappings":";AACA,OAAO,YAAY;;;ACDnB,OAAO,QAAQ;AAER,IAAM,oBAAoB,OAAOA,OAAc,eAAuB;AAC3E,MAAI;AACF,UAAM,iBAAiB,MAAM,GAAG,SAASA,OAAM,OAAO;AACtD,WAAO,mBAAmB;AAAA,EAC5B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;ACTA,SAAS,cAAc;;;ACKhB,IAAM,oBAAoB,OAC/B,KACA,MACA,WACG;AACH,MAAI;AACF,WAAO,MAAM,IACV,KAAK;AAAA,MACJ,QAAQ;AAAA,MACR,MAAM,CAAC,KAAK,MAAM,YAAY,CAAC;AAAA,I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MAAM;AACpC,eAAO,KAAK,4CAAqC;AAEjD,cAAM,MAAM,OAAO,EAChB,IAAI,MAAM,EACV,QAAQ;AAAA,UACP,gBAAgB;AAAA,UAChB,eAAe,UAAU,KAAK;AAAA,QAChC,CAAC;AAEH,oBAAY,YAAY;AACtB,cAAI;AACF,kBAAM,QAAQ;AAAA,cACZ,QAAQ,IAAI,CAAC,WAAW,gBAAgB,KAAK,QAAQ,MAAM,CAAC;AAAA,YAC9D;AAAA,UACF,SAAS,GAAQ;AACf,mBAAO,MAAM,EAAE,WAAW,OAAO,CAAC,CAAC;AAAA,UACrC;AAAA,QACF,GAAG,eAAe;AAAA,MACpB;AAAA,MACA,qBAAqB,OAAO,EAAE,OAAO,MAAM;AACzC,eAAO,KAAK,yBAAyB;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACF;","names":["path","fs","fs"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/has-content-changed.ts","../src/utils/process-tag-group.ts","../src/api/get-date-prop-ident.ts","../src/api/get-page-blocks-tree.ts","../src/api/get-raw-response.ts","../src/utils/recursively-get-content.ts","../src/utils/write-to-md.ts","../src/utils/get-clean-slug.ts"],"sourcesContent":["import { AstroIntegration } from 'astro'\nimport wretch from 'wretch'\n\nimport { LogseqIntegrationOptions } from './types'\nimport { processTagGroup } from './utils'\n\nexport default function logseqIntegration(\n options: LogseqIntegrationOptions,\n): AstroIntegration {\n const {\n token,\n targets,\n dateRef,\n apiUrl = 'http://127.0.0.1:12315/api',\n pollingInterval = 1000,\n } = options\n\n return {\n name: 'astro-logseq-publish',\n hooks: {\n 'astro:server:setup': ({ logger }) => {\n logger.info(`🚀 Logseq Poller Started (Every ${pollingInterval}ms)`)\n\n const api = wretch()\n .url(apiUrl)\n .headers({\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n })\n\n setInterval(async () => {\n try {\n await Promise.all(\n targets.map((target) =>\n processTagGroup(api, dateRef, target, logger),\n ),\n )\n } catch (e: any) {\n logger.error(e.message || String(e))\n }\n }, pollingInterval)\n },\n 'astro:build:setup': async ({ logger }) => {\n logger.info('Building from Logseq...')\n },\n },\n }\n}\n","import fs from \"node:fs/promises\";\n\nexport const hasContentChanged = async (path: string, newContent: string) => {\n try {\n const currentContent = await fs.readFile(path, \"utf-8\");\n return currentContent !== newContent;\n } catch {\n return true;\n }\n};\n","import { AstroIntegrationLogger } from 'astro'\nimport { format, parse } from 'date-fns'\nimport { Wretch } from 'wretch/types'\n\nimport { getDatePropPage, getPageBlocksTree, getRawResponse } from '../api'\nimport { MappedResponse, TagTarget } from '../types'\nimport { recursivelyGetContent, writeToMd } from '.'\n\nexport const processTagGroup = async (\n api: Wretch,\n dateRef: string,\n target: TagTarget,\n logger: AstroIntegrationLogger,\n) => {\n const { tag, directory } = target\n const mappedResponse: MappedResponse[] = []\n\n const datePropPageIdent = await getDatePropPage(api, dateRef, logger)\n\n const rawResponse = await getRawResponse(api, datePropPageIdent, tag, logger)\n if (!rawResponse || rawResponse.length === 0) return\n\n for (const page of rawResponse.flat()) {\n const pbt = await getPageBlocksTree(api, page, logger)\n if (!pbt) continue\n\n mappedResponse.push({\n createdAt: format(page['created-at'], 'yyyy-MM-dd'),\n updatedAt: format(page['updated-at'], 'yyyy-MM-dd'),\n pageTitle: page.title,\n content: recursivelyGetContent(pbt),\n ...(datePropPageIdent && {\n date: parse(\n String(page[datePropPageIdent!]['journal-day']),\n 'yyyyMMdd',\n new Date(),\n ),\n }),\n })\n await writeToMd(directory, mappedResponse, logger)\n }\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { LogseqPageResponse } from 'src/types'\nimport { Wretch } from 'wretch/types'\n\nexport const getDatePropPage = async (\n api: Wretch,\n dateRef: string,\n logger: AstroIntegrationLogger,\n) => {\n try {\n const datePropPage = await api\n .post({\n method: 'logseq.Editor.getPage',\n args: [dateRef],\n })\n .json<LogseqPageResponse>()\n const datePropPageIdent = datePropPage.ident\n return datePropPageIdent\n } catch (e) {\n logger.info(`Unable to get page for date reference: ${String(e)}`)\n }\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { Wretch } from 'wretch/types'\n\nimport { ContentBlock, LogseqPageResponse } from '../types'\n\nexport const getPageBlocksTree = async (\n api: Wretch,\n page: LogseqPageResponse,\n logger: AstroIntegrationLogger,\n) => {\n try {\n return await api\n .post({\n method: 'logseq.Editor.getPageBlocksTree',\n args: [page.title.toLowerCase()],\n })\n .json<ContentBlock[]>()\n } catch (e) {\n logger.info(`Unable to get page blocks tree: ${String(e)}`)\n }\n}\n","import { AstroIntegrationLogger } from 'astro'\nimport { Wretch } from 'wretch/types'\n\nimport { LogseqPageResponse } from '../types'\n\nexport const getRawResponse = async (\n api: Wretch,\n datePropPageIdent: string | undefined,\n tag: string,\n logger: AstroIntegrationLogger,\n) => {\n const query = `\n [:find (pull ?p\n [:block/name\n :block/full-title\n :block/created-at\n :block/updated-at\n :block/title\n ${datePropPageIdent && `{${datePropPageIdent} [:block/journal-day]}`}\n {:block/_parent [:block/uuid]}])\n :where\n [?p :block/name]\n [?p :block/tags ?t]\n [?t :block/name \"${tag}\"]]`\n\n try {\n return (\n (await api\n .post({\n method: 'logseq.DB.datascriptQuery',\n args: [query],\n })\n .json<LogseqPageResponse[][]>()) ?? []\n )\n } catch (e) {\n logger.info(\n `Unable to query Logseq. Check if API server is running. ${String(e)}`,\n )\n }\n}\n","import { ContentBlock } from '../types'\n\nexport const recursivelyGetContent = (\n contentBlocks: ContentBlock[],\n depth = 0,\n) => {\n let content = ''\n const indent = ' '.repeat(depth)\n for (const block of contentBlocks) {\n const text = (block.fullTitle ?? '').replace(\n /(`[^`]+`)|\\[\\[(.*?)\\]\\]/g,\n (_match, code, linkContent) => {\n if (code) return code\n const isCodeDisplay =\n block[':logseq.property.node/display-type'] === 'code'\n return isCodeDisplay\n ? `\\`\\`\\`\\n[[${linkContent}]]\\n\\`\\`\\``\n : linkContent\n },\n )\n if (depth === 0) {\n content += `\\n\\n${text}`\n } else {\n content += `\\n${indent}- ${text}`\n }\n if (block.children && block.children.length > 0) {\n content += recursivelyGetContent(block.children, depth + 1)\n }\n }\n return content\n}\n","import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { AstroIntegrationLogger } from 'astro'\n\nimport { MappedResponse } from '../types'\nimport { hasContentChanged } from '.'\nimport { getCleanSlug } from './get-clean-slug'\n\nexport const writeToMd = async (\n directory: string,\n mappedResponse: MappedResponse[],\n logger: AstroIntegrationLogger,\n) => {\n const targetDir = path.resolve(process.cwd(), directory)\n\n try {\n await fs.mkdir(targetDir, { recursive: true })\n await Promise.all(\n mappedResponse.map(async (page) => {\n const cleanSlug = getCleanSlug(page)\n const filePath = path.join(targetDir, `${cleanSlug}.md`)\n const fileContent = `---\ntitle: ${page.pageTitle}\ndate: ${page.date}\n---\n${page.content}`\n const contentToSave = fileContent.trim()\n if (await hasContentChanged(filePath, contentToSave)) {\n await fs.writeFile(filePath, contentToSave, 'utf-8')\n }\n }),\n )\n } catch (e) {\n logger.info(`Unable to create MD files: ${String(e)}`)\n }\n}\n","import { MappedResponse } from '../types'\n\nexport const getCleanSlug = (page: MappedResponse) =>\n page.pageTitle\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/(^-|-$)/g, '')\n"],"mappings":";AACA,OAAO,YAAY;;;ACDnB,OAAO,QAAQ;AAER,IAAM,oBAAoB,OAAOA,OAAc,eAAuB;AAC3E,MAAI;AACF,UAAM,iBAAiB,MAAM,GAAG,SAASA,OAAM,OAAO;AACtD,WAAO,mBAAmB;AAAA,EAC5B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;ACRA,SAAS,QAAQ,aAAa;;;ACGvB,IAAM,kBAAkB,OAC7B,KACA,SACA,WACG;AACH,MAAI;AACF,UAAM,eAAe,MAAM,IACxB,KAAK;AAAA,MACJ,QAAQ;AAAA,MACR,MAAM,CAAC,OAAO;AAAA,IAChB,CAAC,EACA,KAAyB;AAC5B,UAAM,oBAAoB,aAAa;AACvC,WAAO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