@voidwire/lore 1.0.5 → 1.0.6
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/lib/config.ts +9 -2
- package/lib/db.ts +15 -4
- package/lib/indexers/blogs.ts +9 -2
- package/package.json +1 -1
package/lib/config.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* Usage:
|
|
8
8
|
* import { getConfig } from "./config";
|
|
9
9
|
* const config = getConfig();
|
|
10
|
-
* console.log(config.paths.data); //
|
|
11
|
-
* console.log(config.database.sqlite); //
|
|
10
|
+
* console.log(config.paths.data); // ~/.local/share/lore
|
|
11
|
+
* console.log(config.database.sqlite); // ~/.local/share/lore/lore.db
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { readFileSync } from "fs";
|
|
@@ -27,9 +27,11 @@ export interface LoreConfig {
|
|
|
27
27
|
sable_events?: string;
|
|
28
28
|
flux?: string;
|
|
29
29
|
flux_projects?: string;
|
|
30
|
+
blog_url?: string;
|
|
30
31
|
};
|
|
31
32
|
database: {
|
|
32
33
|
sqlite: string;
|
|
34
|
+
custom_sqlite?: string;
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -129,9 +131,14 @@ export function getConfig(): LoreConfig {
|
|
|
129
131
|
typeof paths.flux_projects === "string"
|
|
130
132
|
? resolvePath(paths.flux_projects)
|
|
131
133
|
: undefined,
|
|
134
|
+
blog_url: typeof paths.blog_url === "string" ? paths.blog_url : undefined,
|
|
132
135
|
},
|
|
133
136
|
database: {
|
|
134
137
|
sqlite: resolvePath(database.sqlite as string),
|
|
138
|
+
custom_sqlite:
|
|
139
|
+
typeof database.custom_sqlite === "string"
|
|
140
|
+
? resolvePath(database.custom_sqlite)
|
|
141
|
+
: undefined,
|
|
135
142
|
},
|
|
136
143
|
};
|
|
137
144
|
|
package/lib/db.ts
CHANGED
|
@@ -9,11 +9,22 @@ import { Database } from "bun:sqlite";
|
|
|
9
9
|
import { existsSync } from "fs";
|
|
10
10
|
import { getConfig } from "./config";
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// Load custom SQLite from config to enable extension loading
|
|
13
13
|
// Must be called before any Database instances are created
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
|
|
14
|
+
const config = getConfig();
|
|
15
|
+
if (config.database.custom_sqlite) {
|
|
16
|
+
if (!existsSync(config.database.custom_sqlite)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
`database.custom_sqlite path does not exist: ${config.database.custom_sqlite}`,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
Database.setCustomSQLite(config.database.custom_sqlite);
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"database.custom_sqlite not set in ~/.config/lore/config.toml.\n" +
|
|
25
|
+
"Required for sqlite-vec extension loading.\n" +
|
|
26
|
+
'macOS: custom_sqlite = "/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib"',
|
|
27
|
+
);
|
|
17
28
|
}
|
|
18
29
|
|
|
19
30
|
/**
|
package/lib/indexers/blogs.ts
CHANGED
|
@@ -42,6 +42,12 @@ export async function indexBlogs(ctx: IndexerContext): Promise<void> {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
if (!ctx.config.paths.blog_url) {
|
|
46
|
+
console.warn(
|
|
47
|
+
"WARNING: paths.blog_url not set in config.toml — blog post URLs will not be generated",
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
const files = walkMarkdownFiles(postsDir);
|
|
46
52
|
|
|
47
53
|
for (const filePath of files) {
|
|
@@ -117,9 +123,10 @@ export async function indexBlogs(ctx: IndexerContext): Promise<void> {
|
|
|
117
123
|
// Topic from categories
|
|
118
124
|
const topic = categories.length > 0 ? categories.join(" ") : "";
|
|
119
125
|
|
|
120
|
-
// URL from slug or filename
|
|
126
|
+
// URL from slug or filename — requires blog_url in config
|
|
127
|
+
const blogUrl = ctx.config.paths.blog_url;
|
|
121
128
|
const urlSlug = slug || basename(filePath, ".md");
|
|
122
|
-
const url =
|
|
129
|
+
const url = blogUrl ? `${blogUrl}/posts/${urlSlug}/` : "";
|
|
123
130
|
|
|
124
131
|
// Word count
|
|
125
132
|
const wordCount = content.split(/\s+/).filter(Boolean).length;
|