folderblog 0.0.2 → 0.0.3

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.
Files changed (61) hide show
  1. package/dist/{chunk-24MKFHML.cjs → chunk-2TZSVPNP.cjs} +5 -0
  2. package/dist/{chunk-HMQIQUPB.cjs → chunk-6TFXNIO6.cjs} +108 -0
  3. package/dist/{chunk-ZRUBI3GH.js → chunk-B43UAOPC.js} +106 -1
  4. package/dist/{chunk-XP5J4LFJ.js → chunk-D26H5722.js} +5 -0
  5. package/dist/chunk-E7PYGJA7.cjs +39 -0
  6. package/dist/{chunk-QA4KPPTA.cjs → chunk-J3Y3HEBF.cjs} +84 -13
  7. package/dist/{chunk-PARGDJNY.js → chunk-K76XLEC7.js} +1 -1
  8. package/dist/{chunk-IXP35S24.js → chunk-LPPBVXJ7.js} +83 -12
  9. package/dist/chunk-Q6EXKX6K.js +17 -0
  10. package/dist/{chunk-4ZJGUMHS.cjs → chunk-Q6EYTOTM.cjs} +2 -2
  11. package/dist/chunk-UCXXH2MP.cjs +20 -0
  12. package/dist/chunk-XQD3UUL5.js +34 -0
  13. package/dist/cli/bin.cjs +5 -5
  14. package/dist/cli/bin.js +4 -4
  15. package/dist/cli/index.cjs +5 -5
  16. package/dist/cli/index.js +4 -4
  17. package/dist/config-ADPY6IQS.d.cts +473 -0
  18. package/dist/config-Dctsdeo6.d.ts +473 -0
  19. package/dist/index.cjs +157 -187
  20. package/dist/index.d.cts +4 -3
  21. package/dist/index.d.ts +4 -3
  22. package/dist/index.js +16 -69
  23. package/dist/local/index.cjs +785 -0
  24. package/dist/local/index.d.cts +268 -0
  25. package/dist/local/index.d.ts +268 -0
  26. package/dist/local/index.js +772 -0
  27. package/dist/output-0P0br3Jc.d.cts +452 -0
  28. package/dist/output-0P0br3Jc.d.ts +452 -0
  29. package/dist/plugins/embed-cloudflare-ai.cjs +166 -0
  30. package/dist/plugins/embed-cloudflare-ai.d.cts +73 -0
  31. package/dist/plugins/embed-cloudflare-ai.d.ts +73 -0
  32. package/dist/plugins/embed-cloudflare-ai.js +156 -0
  33. package/dist/plugins/embed-transformers.cjs +121 -0
  34. package/dist/plugins/embed-transformers.d.cts +55 -0
  35. package/dist/plugins/embed-transformers.d.ts +55 -0
  36. package/dist/plugins/embed-transformers.js +113 -0
  37. package/dist/plugins/similarity.cjs +19 -0
  38. package/dist/plugins/similarity.d.cts +41 -0
  39. package/dist/plugins/similarity.d.ts +41 -0
  40. package/dist/plugins/similarity.js +2 -0
  41. package/dist/processor/index.cjs +123 -111
  42. package/dist/processor/index.d.cts +6 -2
  43. package/dist/processor/index.d.ts +6 -2
  44. package/dist/processor/index.js +3 -3
  45. package/dist/processor/plugins.cjs +24 -12
  46. package/dist/processor/plugins.d.cts +4 -2
  47. package/dist/processor/plugins.d.ts +4 -2
  48. package/dist/processor/plugins.js +1 -1
  49. package/dist/processor/types.cjs +16 -16
  50. package/dist/processor/types.d.cts +3 -2
  51. package/dist/processor/types.d.ts +3 -2
  52. package/dist/processor/types.js +1 -1
  53. package/dist/seo/index.cjs +289 -0
  54. package/dist/seo/index.d.cts +95 -0
  55. package/dist/seo/index.d.ts +95 -0
  56. package/dist/seo/index.js +274 -0
  57. package/dist/server/index.cjs +2 -5
  58. package/dist/server/index.js +2 -5
  59. package/package.json +36 -1
  60. package/dist/config-DFr-htlO.d.cts +0 -887
  61. package/dist/config-DFr-htlO.d.ts +0 -887
@@ -0,0 +1,274 @@
1
+ import '../chunk-3RG5ZIWI.js';
2
+
3
+ // src/seo/index.ts
4
+ function escapeMarkup(str, aposEntity = "'") {
5
+ if (!str) return "";
6
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, aposEntity);
7
+ }
8
+ function escapeXml(str) {
9
+ return escapeMarkup(str, "&apos;");
10
+ }
11
+ function escapeHtml(str) {
12
+ return escapeMarkup(str, "&#039;");
13
+ }
14
+ function makeAbsoluteUrl(path, siteUrl) {
15
+ if (path.startsWith("http://") || path.startsWith("https://")) return path;
16
+ if (path.startsWith("//")) return `https:${path}`;
17
+ if (path.startsWith("/")) return `${siteUrl}${path}`;
18
+ return `${siteUrl}/${path}`;
19
+ }
20
+ function generateMetaTags(site, options) {
21
+ const title = options.title ?? site.siteName;
22
+ const description = options.description ?? site.siteDescription ?? "";
23
+ const image = options.image ?? site.ogImage ?? "";
24
+ const url = options.url ?? site.siteUrl;
25
+ const type = options.type ?? "website";
26
+ const absoluteImage = image ? makeAbsoluteUrl(image, site.siteUrl) : "";
27
+ const tags = [
28
+ { title },
29
+ { name: "description", content: description },
30
+ { tagName: "link", rel: "canonical", href: url },
31
+ { property: "og:title", content: title },
32
+ { property: "og:description", content: description },
33
+ { property: "og:url", content: url },
34
+ { property: "og:type", content: type },
35
+ { property: "og:site_name", content: site.siteName },
36
+ { name: "twitter:card", content: "summary_large_image" },
37
+ { name: "twitter:title", content: title },
38
+ { name: "twitter:description", content: description }
39
+ ];
40
+ if (absoluteImage) {
41
+ tags.push(
42
+ { property: "og:image", content: absoluteImage },
43
+ { name: "twitter:image", content: absoluteImage }
44
+ );
45
+ }
46
+ if (type === "article" && options.article) {
47
+ const { article } = options;
48
+ if (article.publishedTime) {
49
+ tags.push({ property: "article:published_time", content: article.publishedTime });
50
+ }
51
+ if (article.modifiedTime) {
52
+ tags.push({ property: "article:modified_time", content: article.modifiedTime });
53
+ }
54
+ if (article.tags) {
55
+ for (const tag of article.tags) {
56
+ tags.push({ property: "article:tag", content: tag });
57
+ }
58
+ }
59
+ }
60
+ return tags;
61
+ }
62
+ function generatePostMetaTags(site, post, url) {
63
+ return generateMetaTags(site, {
64
+ title: `${post.title} | ${site.siteName}`,
65
+ description: post.description || post.excerpt,
66
+ image: post.coverImage,
67
+ url,
68
+ type: "article",
69
+ article: {
70
+ publishedTime: post.date,
71
+ author: post.authorName ?? site.author?.name,
72
+ tags: post.tags
73
+ }
74
+ });
75
+ }
76
+ function generateListMetaTags(site, title, description, url, pageNumber) {
77
+ const pageTitle = pageNumber && pageNumber > 1 ? `${title} - Page ${pageNumber} | ${site.siteName}` : `${title} | ${site.siteName}`;
78
+ const tags = generateMetaTags(site, {
79
+ title: pageTitle,
80
+ description,
81
+ url,
82
+ type: "website"
83
+ });
84
+ if (pageNumber && pageNumber > 1) {
85
+ tags.push({ name: "robots", content: "noindex, follow" });
86
+ }
87
+ return tags;
88
+ }
89
+ function postToArticleJsonLd(site, post, url) {
90
+ return {
91
+ "@context": "https://schema.org",
92
+ "@type": "BlogPosting",
93
+ headline: post.title,
94
+ description: post.description || post.excerpt,
95
+ author: {
96
+ "@type": post.authorName ? "Person" : "Organization",
97
+ name: post.authorName ?? site.author?.name ?? site.siteName
98
+ },
99
+ publisher: {
100
+ "@type": "Organization",
101
+ name: site.siteName
102
+ },
103
+ datePublished: post.date,
104
+ mainEntityOfPage: { "@type": "WebPage", "@id": url },
105
+ keywords: post.tags?.join(", "),
106
+ ...post.coverImage ? { image: [makeAbsoluteUrl(post.coverImage, site.siteUrl)] } : {}
107
+ };
108
+ }
109
+ function createItemListJsonLd(posts, listName, listDescription, baseUrl) {
110
+ return {
111
+ "@context": "https://schema.org",
112
+ "@type": "ItemList",
113
+ name: listName,
114
+ description: listDescription,
115
+ numberOfItems: posts.length,
116
+ itemListElement: posts.map((post, index) => ({
117
+ "@type": "ListItem",
118
+ position: index + 1,
119
+ url: baseUrl ? `${baseUrl}/${post.slug}` : `/${post.slug}`,
120
+ name: post.title
121
+ }))
122
+ };
123
+ }
124
+ function createBreadcrumbJsonLd(items) {
125
+ return {
126
+ "@context": "https://schema.org",
127
+ "@type": "BreadcrumbList",
128
+ itemListElement: items.map((item, index) => ({
129
+ "@type": "ListItem",
130
+ position: index + 1,
131
+ name: item.name,
132
+ item: item.url
133
+ }))
134
+ };
135
+ }
136
+ function createOrganizationJsonLd(site) {
137
+ const sameAs = [];
138
+ if (site.social?.twitter) sameAs.push(site.social.twitter);
139
+ if (site.social?.github) sameAs.push(site.social.github);
140
+ return {
141
+ "@context": "https://schema.org",
142
+ "@type": "Organization",
143
+ name: site.siteName,
144
+ url: site.siteUrl,
145
+ description: site.siteDescription,
146
+ ...sameAs.length > 0 ? { sameAs } : {}
147
+ };
148
+ }
149
+ function createWebsiteJsonLd(site, searchUrl) {
150
+ const jsonLd = {
151
+ "@context": "https://schema.org",
152
+ "@type": "WebSite",
153
+ name: site.siteName,
154
+ url: site.siteUrl,
155
+ description: site.siteDescription
156
+ };
157
+ if (searchUrl) {
158
+ jsonLd.potentialAction = {
159
+ "@type": "SearchAction",
160
+ target: {
161
+ "@type": "EntryPoint",
162
+ urlTemplate: searchUrl
163
+ },
164
+ "query-input": "required name=search_term_string"
165
+ };
166
+ }
167
+ return jsonLd;
168
+ }
169
+ function serializeJsonLd(jsonLd) {
170
+ return JSON.stringify(jsonLd, null, 2);
171
+ }
172
+ function generateRssFeed(options) {
173
+ const feedUrl = `${options.baseUrl}/api/feed.xml`;
174
+ const postPath = options.postPath ?? "/posts";
175
+ return `<?xml version="1.0" encoding="UTF-8"?>
176
+ <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
177
+ <channel>
178
+ <title>${escapeXml(options.title)}</title>
179
+ <description>${escapeXml(options.description)}</description>
180
+ <link>${escapeXml(options.baseUrl)}</link>
181
+ <atom:link href="${escapeXml(feedUrl)}" rel="self" type="application/rss+xml"/>
182
+ <lastBuildDate>${(/* @__PURE__ */ new Date()).toUTCString()}</lastBuildDate>
183
+ ${options.posts.map((post) => {
184
+ const postUrl = `${options.baseUrl}${postPath}/${encodeURIComponent(post.slug)}`;
185
+ return `
186
+ <item>
187
+ <title>${escapeXml(post.title)}</title>
188
+ <link>${escapeXml(postUrl)}</link>
189
+ <guid isPermaLink="true">${escapeXml(postUrl)}</guid>
190
+ <description>${escapeXml(post.description || post.excerpt)}</description>
191
+ ${post.date ? `<pubDate>${new Date(post.date).toUTCString()}</pubDate>` : ""}
192
+ ${(post.tags ?? []).map((tag) => `<category>${escapeXml(tag)}</category>`).join("\n ")}
193
+ </item>`;
194
+ }).join("")}
195
+ </channel>
196
+ </rss>`;
197
+ }
198
+ function generateJsonFeed(options) {
199
+ const postPath = options.postPath ?? "/posts";
200
+ return {
201
+ version: "https://jsonfeed.org/version/1.1",
202
+ title: options.title,
203
+ description: options.description,
204
+ home_page_url: options.baseUrl,
205
+ feed_url: `${options.baseUrl}/api/feed.json`,
206
+ icon: options.logo,
207
+ items: options.posts.map((post) => {
208
+ const postUrl = `${options.baseUrl}${postPath}/${encodeURIComponent(post.slug)}`;
209
+ return {
210
+ id: postUrl,
211
+ url: postUrl,
212
+ title: post.title,
213
+ summary: post.description || post.excerpt,
214
+ image: post.coverImage,
215
+ date_published: post.date,
216
+ authors: post.authorName ? [{ name: post.authorName }] : [],
217
+ tags: post.tags
218
+ };
219
+ })
220
+ };
221
+ }
222
+ function generateSitemap(baseUrl, posts, options) {
223
+ const postPath = options?.postPath ?? "/posts";
224
+ return `<?xml version="1.0" encoding="UTF-8"?>
225
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
226
+ <url>
227
+ <loc>${escapeXml(baseUrl)}</loc>
228
+ <changefreq>daily</changefreq>
229
+ <priority>1.0</priority>
230
+ </url>
231
+ ${posts.map((post) => {
232
+ const postUrl = `${baseUrl}${postPath}/${encodeURIComponent(post.slug)}`;
233
+ return `
234
+ <url>
235
+ <loc>${escapeXml(postUrl)}</loc>
236
+ ${post.date ? `<lastmod>${new Date(post.date).toISOString().split("T")[0]}</lastmod>` : ""}
237
+ <changefreq>weekly</changefreq>
238
+ <priority>0.8</priority>
239
+ </url>`;
240
+ }).join("")}
241
+ </urlset>`;
242
+ }
243
+ function generateRobotsTxt(sitemapUrl, options) {
244
+ const lines = ["User-agent: *"];
245
+ if (options?.allowPaths) {
246
+ for (const path of options.allowPaths) {
247
+ lines.push(`Allow: ${path}`);
248
+ }
249
+ }
250
+ if (options?.disallowPaths) {
251
+ for (const path of options.disallowPaths) {
252
+ lines.push(`Disallow: ${path}`);
253
+ }
254
+ }
255
+ lines.push("", `Sitemap: ${sitemapUrl}`);
256
+ return lines.join("\n");
257
+ }
258
+ function metaTagsToHtml(tags) {
259
+ return tags.map((tag) => {
260
+ if (tag.title) return `<title>${escapeHtml(tag.title)}</title>`;
261
+ if (tag.tagName === "link") {
262
+ return `<link rel="${escapeHtml(tag.rel)}" href="${escapeHtml(tag.href)}">`;
263
+ }
264
+ if (tag.property) {
265
+ return `<meta property="${escapeHtml(tag.property)}" content="${escapeHtml(tag.content)}">`;
266
+ }
267
+ if (tag.name) {
268
+ return `<meta name="${escapeHtml(tag.name)}" content="${escapeHtml(tag.content)}">`;
269
+ }
270
+ return "";
271
+ }).filter(Boolean).join("\n");
272
+ }
273
+
274
+ export { createBreadcrumbJsonLd, createItemListJsonLd, createOrganizationJsonLd, createWebsiteJsonLd, generateJsonFeed, generateListMetaTags, generateMetaTags, generatePostMetaTags, generateRobotsTxt, generateRssFeed, generateSitemap, metaTagsToHtml, postToArticleJsonLd, serializeJsonLd };
@@ -1,15 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var chunkUCXXH2MP_cjs = require('../chunk-UCXXH2MP.cjs');
3
4
  require('../chunk-OBGZSXTJ.cjs');
4
5
 
5
6
  // src/server/index.ts
6
7
  function createHandler(options) {
7
8
  const { domain, basePath, fetch: fetchFn = globalThis.fetch } = options;
8
- let baseUrl = domain.trim();
9
- if (baseUrl.endsWith("/")) baseUrl = baseUrl.slice(0, -1);
10
- if (!baseUrl.startsWith("http://") && !baseUrl.startsWith("https://")) {
11
- baseUrl = `https://${baseUrl}`;
12
- }
9
+ const baseUrl = chunkUCXXH2MP_cjs.normalizeBaseUrl(domain);
13
10
  const prefix = basePath ? basePath.replace(/\/$/, "") : "";
14
11
  return async (request) => {
15
12
  const url = new URL(request.url);
@@ -1,13 +1,10 @@
1
+ import { normalizeBaseUrl } from '../chunk-Q6EXKX6K.js';
1
2
  import '../chunk-3RG5ZIWI.js';
2
3
 
3
4
  // src/server/index.ts
4
5
  function createHandler(options) {
5
6
  const { domain, basePath, fetch: fetchFn = globalThis.fetch } = options;
6
- let baseUrl = domain.trim();
7
- if (baseUrl.endsWith("/")) baseUrl = baseUrl.slice(0, -1);
8
- if (!baseUrl.startsWith("http://") && !baseUrl.startsWith("https://")) {
9
- baseUrl = `https://${baseUrl}`;
10
- }
7
+ const baseUrl = normalizeBaseUrl(domain);
11
8
  const prefix = basePath ? basePath.replace(/\/$/, "") : "";
12
9
  return async (request) => {
13
10
  const url = new URL(request.url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "folderblog",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Official SDK for folder.blog — client, server middleware, and markdown processing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,6 +12,11 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
+ "./local": {
16
+ "types": "./dist/local/index.d.ts",
17
+ "import": "./dist/local/index.js",
18
+ "require": "./dist/local/index.cjs"
19
+ },
15
20
  "./processor": {
16
21
  "types": "./dist/processor/index.d.ts",
17
22
  "import": "./dist/processor/index.js",
@@ -27,6 +32,11 @@
27
32
  "import": "./dist/processor/types.js",
28
33
  "require": "./dist/processor/types.cjs"
29
34
  },
35
+ "./seo": {
36
+ "types": "./dist/seo/index.d.ts",
37
+ "import": "./dist/seo/index.js",
38
+ "require": "./dist/seo/index.cjs"
39
+ },
30
40
  "./server": {
31
41
  "types": "./dist/server/index.d.ts",
32
42
  "import": "./dist/server/index.js",
@@ -37,6 +47,21 @@
37
47
  "import": "./dist/cli/index.js",
38
48
  "require": "./dist/cli/index.cjs"
39
49
  },
50
+ "./plugins/embed-transformers": {
51
+ "types": "./dist/plugins/embed-transformers.d.ts",
52
+ "import": "./dist/plugins/embed-transformers.js",
53
+ "require": "./dist/plugins/embed-transformers.cjs"
54
+ },
55
+ "./plugins/embed-cloudflare-ai": {
56
+ "types": "./dist/plugins/embed-cloudflare-ai.d.ts",
57
+ "import": "./dist/plugins/embed-cloudflare-ai.js",
58
+ "require": "./dist/plugins/embed-cloudflare-ai.cjs"
59
+ },
60
+ "./plugins/similarity": {
61
+ "types": "./dist/plugins/similarity.d.ts",
62
+ "import": "./dist/plugins/similarity.js",
63
+ "require": "./dist/plugins/similarity.cjs"
64
+ },
40
65
  "./package.json": "./package.json"
41
66
  },
42
67
  "bin": {
@@ -60,6 +85,7 @@
60
85
  "gray-matter": "^4.0.3",
61
86
  "hast-util-to-string": "^3.0.1",
62
87
  "mdast-util-to-string": "^4.0.0",
88
+ "minisearch": "^7.2.0",
63
89
  "rehype-autolink-headings": "^7.1.0",
64
90
  "rehype-external-links": "^3.0.0",
65
91
  "rehype-raw": "^7.0.0",
@@ -75,6 +101,7 @@
75
101
  },
76
102
  "devDependencies": {
77
103
  "@folderblog/processor": "workspace:*",
104
+ "@huggingface/transformers": "^3.8.1",
78
105
  "@types/node": "^22.0.0",
79
106
  "tsup": "^8.0.0",
80
107
  "typescript": "^5.7.2",
@@ -99,6 +126,14 @@
99
126
  "type": "git",
100
127
  "url": "https://github.com/iplanwebsites/folder-blog-mono"
101
128
  },
129
+ "peerDependencies": {
130
+ "@huggingface/transformers": ">=3.0.0"
131
+ },
132
+ "peerDependenciesMeta": {
133
+ "@huggingface/transformers": {
134
+ "optional": true
135
+ }
136
+ },
102
137
  "sideEffects": false,
103
138
  "engines": {
104
139
  "node": ">=18.0.0"