bunki 0.3.8 → 0.4.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/README.md +12 -0
- package/dist/cli.js +80 -12
- package/dist/index.d.ts +3 -3
- package/dist/index.js +80 -12
- package/dist/site-generator.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -319,6 +319,18 @@ Your post content goes here with **markdown** support!
|
|
|
319
319
|
```javascript
|
|
320
320
|
console.log("Code highlighting works too!");
|
|
321
321
|
```
|
|
322
|
+
|
|
323
|
+
You can also embed videos using HTML5 video tags:
|
|
324
|
+
|
|
325
|
+
<video src="https://example.com/video.mp4" controls width="640" height="360"></video>
|
|
326
|
+
|
|
327
|
+
Or with multiple formats for better browser compatibility:
|
|
328
|
+
|
|
329
|
+
<video controls width="640" height="360" poster="thumbnail.jpg">
|
|
330
|
+
<source src="video.mp4" type="video/mp4">
|
|
331
|
+
<source src="video.webm" type="video/webm">
|
|
332
|
+
Your browser does not support the video tag.
|
|
333
|
+
</video>
|
|
322
334
|
````
|
|
323
335
|
|
|
324
336
|
````
|
package/dist/cli.js
CHANGED
|
@@ -32721,6 +32721,7 @@ marked.use({
|
|
|
32721
32721
|
},
|
|
32722
32722
|
postprocess(html) {
|
|
32723
32723
|
html = html.replace(/<a href="(https?:\/\/(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)[^"]*)"[^>]*>(.*?)<\/a>/g, '<div class="video-container"><iframe src="https://www.youtube.com/embed/$4" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen loading="lazy"></iframe></div>');
|
|
32724
|
+
html = html.replace(/<img /g, '<img loading="lazy" ');
|
|
32724
32725
|
return html.replace(/<a href="(https?:\/\/|\/\/)([^"]+)"/g, '<a href="$1$2" target="_blank" rel="noopener noreferrer"');
|
|
32725
32726
|
}
|
|
32726
32727
|
}
|
|
@@ -32750,7 +32751,7 @@ function convertMarkdownToHtml(markdownContent) {
|
|
|
32750
32751
|
allowedAttributes: {
|
|
32751
32752
|
...import_sanitize_html.default.defaults.allowedAttributes,
|
|
32752
32753
|
a: ["href", "name", "target", "rel", "title"],
|
|
32753
|
-
img: ["src", "alt", "title"],
|
|
32754
|
+
img: ["src", "alt", "title", "loading"],
|
|
32754
32755
|
code: ["class"],
|
|
32755
32756
|
pre: ["class"],
|
|
32756
32757
|
span: ["class", "style"],
|
|
@@ -33101,6 +33102,7 @@ class SiteGenerator {
|
|
|
33101
33102
|
await this.generateYearArchives();
|
|
33102
33103
|
await this.generateRSSFeed();
|
|
33103
33104
|
await this.generateSitemap();
|
|
33105
|
+
await this.generateRobotsTxt();
|
|
33104
33106
|
await this.copyStaticAssets();
|
|
33105
33107
|
console.log("Site generation complete!");
|
|
33106
33108
|
}
|
|
@@ -33281,7 +33283,9 @@ class SiteGenerator {
|
|
|
33281
33283
|
}
|
|
33282
33284
|
if (await dirExists(publicDir)) {
|
|
33283
33285
|
const copyRecursive = async (srcDir) => {
|
|
33284
|
-
const entries = await fs3.promises.readdir(srcDir, {
|
|
33286
|
+
const entries = await fs3.promises.readdir(srcDir, {
|
|
33287
|
+
withFileTypes: true
|
|
33288
|
+
});
|
|
33285
33289
|
for (const entry of entries) {
|
|
33286
33290
|
const srcPath = path5.join(srcDir, entry.name);
|
|
33287
33291
|
const relativePath = path5.relative(publicDir, srcPath);
|
|
@@ -33337,6 +33341,20 @@ ${rssItems}
|
|
|
33337
33341
|
const currentDate = this.getPacificDate(new Date).toISOString();
|
|
33338
33342
|
const pageSize = 10;
|
|
33339
33343
|
const config = this.options.config;
|
|
33344
|
+
const now = this.getPacificDate(new Date).getTime();
|
|
33345
|
+
const ONE_DAY = 24 * 60 * 60 * 1000;
|
|
33346
|
+
const ONE_WEEK = 7 * ONE_DAY;
|
|
33347
|
+
const ONE_MONTH = 30 * ONE_DAY;
|
|
33348
|
+
const calculatePriority = (date, basePriority) => {
|
|
33349
|
+
const postTime = new Date(date).getTime();
|
|
33350
|
+
const age = now - postTime;
|
|
33351
|
+
if (age < ONE_WEEK) {
|
|
33352
|
+
return Math.min(1, basePriority + 0.2);
|
|
33353
|
+
} else if (age < ONE_MONTH) {
|
|
33354
|
+
return Math.min(1, basePriority + 0.1);
|
|
33355
|
+
}
|
|
33356
|
+
return basePriority;
|
|
33357
|
+
};
|
|
33340
33358
|
let sitemapContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
33341
33359
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
33342
33360
|
`;
|
|
@@ -33354,7 +33372,7 @@ ${rssItems}
|
|
|
33354
33372
|
<loc>${config.baseUrl}/page/${page}/</loc>
|
|
33355
33373
|
<lastmod>${currentDate}</lastmod>
|
|
33356
33374
|
<changefreq>daily</changefreq>
|
|
33357
|
-
<priority>0.
|
|
33375
|
+
<priority>0.8</priority>
|
|
33358
33376
|
</url>
|
|
33359
33377
|
`;
|
|
33360
33378
|
}
|
|
@@ -33362,11 +33380,14 @@ ${rssItems}
|
|
|
33362
33380
|
for (const post of this.site.posts) {
|
|
33363
33381
|
const postUrl = `${config.baseUrl}${post.url}`;
|
|
33364
33382
|
const postDate = new Date(post.date).toISOString();
|
|
33383
|
+
const priority = calculatePriority(post.date, 0.7);
|
|
33384
|
+
const age = now - new Date(post.date).getTime();
|
|
33385
|
+
const changefreq = age < ONE_MONTH ? "weekly" : "monthly";
|
|
33365
33386
|
sitemapContent += ` <url>
|
|
33366
33387
|
<loc>${postUrl}</loc>
|
|
33367
33388
|
<lastmod>${postDate}</lastmod>
|
|
33368
|
-
<changefreq
|
|
33369
|
-
<priority
|
|
33389
|
+
<changefreq>${changefreq}</changefreq>
|
|
33390
|
+
<priority>${priority.toFixed(1)}</priority>
|
|
33370
33391
|
</url>
|
|
33371
33392
|
`;
|
|
33372
33393
|
}
|
|
@@ -33374,16 +33395,18 @@ ${rssItems}
|
|
|
33374
33395
|
<loc>${config.baseUrl}/tags/</loc>
|
|
33375
33396
|
<lastmod>${currentDate}</lastmod>
|
|
33376
33397
|
<changefreq>weekly</changefreq>
|
|
33377
|
-
<priority>0.
|
|
33398
|
+
<priority>0.5</priority>
|
|
33378
33399
|
</url>
|
|
33379
33400
|
`;
|
|
33380
33401
|
for (const [, tagData] of Object.entries(this.site.tags)) {
|
|
33381
33402
|
const tagUrl = `${config.baseUrl}/tags/${tagData.slug}/`;
|
|
33403
|
+
const mostRecentPost = tagData.posts[0];
|
|
33404
|
+
const tagPriority = mostRecentPost ? calculatePriority(mostRecentPost.date, 0.4) : 0.4;
|
|
33382
33405
|
sitemapContent += ` <url>
|
|
33383
33406
|
<loc>${tagUrl}</loc>
|
|
33384
33407
|
<lastmod>${currentDate}</lastmod>
|
|
33385
33408
|
<changefreq>weekly</changefreq>
|
|
33386
|
-
<priority
|
|
33409
|
+
<priority>${tagPriority.toFixed(1)}</priority>
|
|
33387
33410
|
</url>
|
|
33388
33411
|
`;
|
|
33389
33412
|
const totalTagPages = Math.ceil(tagData.posts.length / pageSize);
|
|
@@ -33393,7 +33416,7 @@ ${rssItems}
|
|
|
33393
33416
|
<loc>${config.baseUrl}/tags/${tagData.slug}/page/${page}/</loc>
|
|
33394
33417
|
<lastmod>${currentDate}</lastmod>
|
|
33395
33418
|
<changefreq>weekly</changefreq>
|
|
33396
|
-
<priority
|
|
33419
|
+
<priority>${Math.max(0.3, tagPriority - 0.1).toFixed(1)}</priority>
|
|
33397
33420
|
</url>
|
|
33398
33421
|
`;
|
|
33399
33422
|
}
|
|
@@ -33409,11 +33432,14 @@ ${rssItems}
|
|
|
33409
33432
|
postsByYear[year].push(post);
|
|
33410
33433
|
}
|
|
33411
33434
|
for (const [year, yearPosts] of Object.entries(postsByYear)) {
|
|
33435
|
+
const currentYear = new Date().getFullYear();
|
|
33436
|
+
const isCurrentYear = parseInt(year) === currentYear;
|
|
33437
|
+
const yearPriority = isCurrentYear ? 0.7 : 0.5;
|
|
33412
33438
|
sitemapContent += ` <url>
|
|
33413
33439
|
<loc>${config.baseUrl}/${year}/</loc>
|
|
33414
33440
|
<lastmod>${currentDate}</lastmod>
|
|
33415
|
-
<changefreq
|
|
33416
|
-
<priority
|
|
33441
|
+
<changefreq>${isCurrentYear ? "weekly" : "monthly"}</changefreq>
|
|
33442
|
+
<priority>${yearPriority.toFixed(1)}</priority>
|
|
33417
33443
|
</url>
|
|
33418
33444
|
`;
|
|
33419
33445
|
const totalYearPages = Math.ceil(yearPosts.length / pageSize);
|
|
@@ -33422,8 +33448,8 @@ ${rssItems}
|
|
|
33422
33448
|
sitemapContent += ` <url>
|
|
33423
33449
|
<loc>${config.baseUrl}/${year}/page/${page}/</loc>
|
|
33424
33450
|
<lastmod>${currentDate}</lastmod>
|
|
33425
|
-
<changefreq
|
|
33426
|
-
<priority
|
|
33451
|
+
<changefreq>${isCurrentYear ? "weekly" : "monthly"}</changefreq>
|
|
33452
|
+
<priority>${(yearPriority - 0.1).toFixed(1)}</priority>
|
|
33427
33453
|
</url>
|
|
33428
33454
|
`;
|
|
33429
33455
|
}
|
|
@@ -33432,6 +33458,48 @@ ${rssItems}
|
|
|
33432
33458
|
sitemapContent += `</urlset>`;
|
|
33433
33459
|
await Bun.write(path5.join(this.options.outputDir, "sitemap.xml"), sitemapContent);
|
|
33434
33460
|
console.log("Generated sitemap.xml");
|
|
33461
|
+
const urlCount = this.site.posts.length + Object.keys(this.site.tags).length + 10;
|
|
33462
|
+
const sitemapSize = sitemapContent.length;
|
|
33463
|
+
if (urlCount > 1000 || sitemapSize > 40000) {
|
|
33464
|
+
await this.generateSitemapIndex();
|
|
33465
|
+
}
|
|
33466
|
+
}
|
|
33467
|
+
async generateSitemapIndex() {
|
|
33468
|
+
const currentDate = this.getPacificDate(new Date).toISOString();
|
|
33469
|
+
const config = this.options.config;
|
|
33470
|
+
let sitemapIndexContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
33471
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
33472
|
+
`;
|
|
33473
|
+
sitemapIndexContent += ` <sitemap>
|
|
33474
|
+
<loc>${config.baseUrl}/sitemap.xml</loc>
|
|
33475
|
+
<lastmod>${currentDate}</lastmod>
|
|
33476
|
+
</sitemap>
|
|
33477
|
+
`;
|
|
33478
|
+
sitemapIndexContent += `</sitemapindex>`;
|
|
33479
|
+
await Bun.write(path5.join(this.options.outputDir, "sitemap_index.xml"), sitemapIndexContent);
|
|
33480
|
+
console.log("Generated sitemap_index.xml");
|
|
33481
|
+
}
|
|
33482
|
+
async generateRobotsTxt() {
|
|
33483
|
+
const config = this.options.config;
|
|
33484
|
+
const robotsTxtContent = `# Robots.txt for ${config.domain}
|
|
33485
|
+
# Generated by Bunki
|
|
33486
|
+
|
|
33487
|
+
User-agent: *
|
|
33488
|
+
Allow: /
|
|
33489
|
+
|
|
33490
|
+
# Sitemaps
|
|
33491
|
+
Sitemap: ${config.baseUrl}/sitemap.xml
|
|
33492
|
+
|
|
33493
|
+
# Crawl-delay (optional, adjust as needed)
|
|
33494
|
+
# Crawl-delay: 1
|
|
33495
|
+
|
|
33496
|
+
# Disallow specific paths (uncomment as needed)
|
|
33497
|
+
# Disallow: /private/
|
|
33498
|
+
# Disallow: /admin/
|
|
33499
|
+
# Disallow: /api/
|
|
33500
|
+
`;
|
|
33501
|
+
await Bun.write(path5.join(this.options.outputDir, "robots.txt"), robotsTxtContent);
|
|
33502
|
+
console.log("Generated robots.txt");
|
|
33435
33503
|
}
|
|
33436
33504
|
}
|
|
33437
33505
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export * from "./types";
|
|
|
2
2
|
export { parseMarkdownDirectory } from "./parser";
|
|
3
3
|
export { startServer } from "./server";
|
|
4
4
|
export { SiteGenerator } from "./site-generator";
|
|
5
|
-
export { configExists, createDefaultConfig, DEFAULT_CONFIG_FILE, DEFAULT_CONTENT_DIR, DEFAULT_OUTPUT_DIR, DEFAULT_TEMPLATES_DIR, loadConfig, saveConfig } from "./config";
|
|
6
|
-
export { copyFile, ensureDir, fileExists, findFilesByPattern, getBaseFilename, readFileAsText } from "./utils/file-utils";
|
|
7
|
-
export { convertMarkdownToHtml, extractExcerpt, parseMarkdownFile } from "./utils/markdown-utils";
|
|
5
|
+
export { configExists, createDefaultConfig, DEFAULT_CONFIG_FILE, DEFAULT_CONTENT_DIR, DEFAULT_OUTPUT_DIR, DEFAULT_TEMPLATES_DIR, loadConfig, saveConfig, } from "./config";
|
|
6
|
+
export { copyFile, ensureDir, fileExists, findFilesByPattern, getBaseFilename, readFileAsText, } from "./utils/file-utils";
|
|
7
|
+
export { convertMarkdownToHtml, extractExcerpt, parseMarkdownFile, } from "./utils/markdown-utils";
|
|
8
8
|
export { DEFAULT_IMAGES_DIR, uploadImages } from "./utils/image-uploader";
|
|
9
9
|
export { createUploader } from "./utils/s3-uploader";
|
package/dist/index.js
CHANGED
|
@@ -30366,6 +30366,7 @@ marked.use({
|
|
|
30366
30366
|
},
|
|
30367
30367
|
postprocess(html) {
|
|
30368
30368
|
html = html.replace(/<a href="(https?:\/\/(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)[^"]*)"[^>]*>(.*?)<\/a>/g, '<div class="video-container"><iframe src="https://www.youtube.com/embed/$4" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen loading="lazy"></iframe></div>');
|
|
30369
|
+
html = html.replace(/<img /g, '<img loading="lazy" ');
|
|
30369
30370
|
return html.replace(/<a href="(https?:\/\/|\/\/)([^"]+)"/g, '<a href="$1$2" target="_blank" rel="noopener noreferrer"');
|
|
30370
30371
|
}
|
|
30371
30372
|
}
|
|
@@ -30395,7 +30396,7 @@ function convertMarkdownToHtml(markdownContent) {
|
|
|
30395
30396
|
allowedAttributes: {
|
|
30396
30397
|
...import_sanitize_html.default.defaults.allowedAttributes,
|
|
30397
30398
|
a: ["href", "name", "target", "rel", "title"],
|
|
30398
|
-
img: ["src", "alt", "title"],
|
|
30399
|
+
img: ["src", "alt", "title", "loading"],
|
|
30399
30400
|
code: ["class"],
|
|
30400
30401
|
pre: ["class"],
|
|
30401
30402
|
span: ["class", "style"],
|
|
@@ -30973,6 +30974,7 @@ class SiteGenerator {
|
|
|
30973
30974
|
await this.generateYearArchives();
|
|
30974
30975
|
await this.generateRSSFeed();
|
|
30975
30976
|
await this.generateSitemap();
|
|
30977
|
+
await this.generateRobotsTxt();
|
|
30976
30978
|
await this.copyStaticAssets();
|
|
30977
30979
|
console.log("Site generation complete!");
|
|
30978
30980
|
}
|
|
@@ -31153,7 +31155,9 @@ class SiteGenerator {
|
|
|
31153
31155
|
}
|
|
31154
31156
|
if (await dirExists(publicDir)) {
|
|
31155
31157
|
const copyRecursive = async (srcDir) => {
|
|
31156
|
-
const entries = await fs3.promises.readdir(srcDir, {
|
|
31158
|
+
const entries = await fs3.promises.readdir(srcDir, {
|
|
31159
|
+
withFileTypes: true
|
|
31160
|
+
});
|
|
31157
31161
|
for (const entry of entries) {
|
|
31158
31162
|
const srcPath = path5.join(srcDir, entry.name);
|
|
31159
31163
|
const relativePath = path5.relative(publicDir, srcPath);
|
|
@@ -31209,6 +31213,20 @@ ${rssItems}
|
|
|
31209
31213
|
const currentDate = this.getPacificDate(new Date).toISOString();
|
|
31210
31214
|
const pageSize = 10;
|
|
31211
31215
|
const config = this.options.config;
|
|
31216
|
+
const now = this.getPacificDate(new Date).getTime();
|
|
31217
|
+
const ONE_DAY = 24 * 60 * 60 * 1000;
|
|
31218
|
+
const ONE_WEEK = 7 * ONE_DAY;
|
|
31219
|
+
const ONE_MONTH = 30 * ONE_DAY;
|
|
31220
|
+
const calculatePriority = (date, basePriority) => {
|
|
31221
|
+
const postTime = new Date(date).getTime();
|
|
31222
|
+
const age = now - postTime;
|
|
31223
|
+
if (age < ONE_WEEK) {
|
|
31224
|
+
return Math.min(1, basePriority + 0.2);
|
|
31225
|
+
} else if (age < ONE_MONTH) {
|
|
31226
|
+
return Math.min(1, basePriority + 0.1);
|
|
31227
|
+
}
|
|
31228
|
+
return basePriority;
|
|
31229
|
+
};
|
|
31212
31230
|
let sitemapContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
31213
31231
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
31214
31232
|
`;
|
|
@@ -31226,7 +31244,7 @@ ${rssItems}
|
|
|
31226
31244
|
<loc>${config.baseUrl}/page/${page}/</loc>
|
|
31227
31245
|
<lastmod>${currentDate}</lastmod>
|
|
31228
31246
|
<changefreq>daily</changefreq>
|
|
31229
|
-
<priority>0.
|
|
31247
|
+
<priority>0.8</priority>
|
|
31230
31248
|
</url>
|
|
31231
31249
|
`;
|
|
31232
31250
|
}
|
|
@@ -31234,11 +31252,14 @@ ${rssItems}
|
|
|
31234
31252
|
for (const post of this.site.posts) {
|
|
31235
31253
|
const postUrl = `${config.baseUrl}${post.url}`;
|
|
31236
31254
|
const postDate = new Date(post.date).toISOString();
|
|
31255
|
+
const priority = calculatePriority(post.date, 0.7);
|
|
31256
|
+
const age = now - new Date(post.date).getTime();
|
|
31257
|
+
const changefreq = age < ONE_MONTH ? "weekly" : "monthly";
|
|
31237
31258
|
sitemapContent += ` <url>
|
|
31238
31259
|
<loc>${postUrl}</loc>
|
|
31239
31260
|
<lastmod>${postDate}</lastmod>
|
|
31240
|
-
<changefreq
|
|
31241
|
-
<priority
|
|
31261
|
+
<changefreq>${changefreq}</changefreq>
|
|
31262
|
+
<priority>${priority.toFixed(1)}</priority>
|
|
31242
31263
|
</url>
|
|
31243
31264
|
`;
|
|
31244
31265
|
}
|
|
@@ -31246,16 +31267,18 @@ ${rssItems}
|
|
|
31246
31267
|
<loc>${config.baseUrl}/tags/</loc>
|
|
31247
31268
|
<lastmod>${currentDate}</lastmod>
|
|
31248
31269
|
<changefreq>weekly</changefreq>
|
|
31249
|
-
<priority>0.
|
|
31270
|
+
<priority>0.5</priority>
|
|
31250
31271
|
</url>
|
|
31251
31272
|
`;
|
|
31252
31273
|
for (const [, tagData] of Object.entries(this.site.tags)) {
|
|
31253
31274
|
const tagUrl = `${config.baseUrl}/tags/${tagData.slug}/`;
|
|
31275
|
+
const mostRecentPost = tagData.posts[0];
|
|
31276
|
+
const tagPriority = mostRecentPost ? calculatePriority(mostRecentPost.date, 0.4) : 0.4;
|
|
31254
31277
|
sitemapContent += ` <url>
|
|
31255
31278
|
<loc>${tagUrl}</loc>
|
|
31256
31279
|
<lastmod>${currentDate}</lastmod>
|
|
31257
31280
|
<changefreq>weekly</changefreq>
|
|
31258
|
-
<priority
|
|
31281
|
+
<priority>${tagPriority.toFixed(1)}</priority>
|
|
31259
31282
|
</url>
|
|
31260
31283
|
`;
|
|
31261
31284
|
const totalTagPages = Math.ceil(tagData.posts.length / pageSize);
|
|
@@ -31265,7 +31288,7 @@ ${rssItems}
|
|
|
31265
31288
|
<loc>${config.baseUrl}/tags/${tagData.slug}/page/${page}/</loc>
|
|
31266
31289
|
<lastmod>${currentDate}</lastmod>
|
|
31267
31290
|
<changefreq>weekly</changefreq>
|
|
31268
|
-
<priority
|
|
31291
|
+
<priority>${Math.max(0.3, tagPriority - 0.1).toFixed(1)}</priority>
|
|
31269
31292
|
</url>
|
|
31270
31293
|
`;
|
|
31271
31294
|
}
|
|
@@ -31281,11 +31304,14 @@ ${rssItems}
|
|
|
31281
31304
|
postsByYear[year].push(post);
|
|
31282
31305
|
}
|
|
31283
31306
|
for (const [year, yearPosts] of Object.entries(postsByYear)) {
|
|
31307
|
+
const currentYear = new Date().getFullYear();
|
|
31308
|
+
const isCurrentYear = parseInt(year) === currentYear;
|
|
31309
|
+
const yearPriority = isCurrentYear ? 0.7 : 0.5;
|
|
31284
31310
|
sitemapContent += ` <url>
|
|
31285
31311
|
<loc>${config.baseUrl}/${year}/</loc>
|
|
31286
31312
|
<lastmod>${currentDate}</lastmod>
|
|
31287
|
-
<changefreq
|
|
31288
|
-
<priority
|
|
31313
|
+
<changefreq>${isCurrentYear ? "weekly" : "monthly"}</changefreq>
|
|
31314
|
+
<priority>${yearPriority.toFixed(1)}</priority>
|
|
31289
31315
|
</url>
|
|
31290
31316
|
`;
|
|
31291
31317
|
const totalYearPages = Math.ceil(yearPosts.length / pageSize);
|
|
@@ -31294,8 +31320,8 @@ ${rssItems}
|
|
|
31294
31320
|
sitemapContent += ` <url>
|
|
31295
31321
|
<loc>${config.baseUrl}/${year}/page/${page}/</loc>
|
|
31296
31322
|
<lastmod>${currentDate}</lastmod>
|
|
31297
|
-
<changefreq
|
|
31298
|
-
<priority
|
|
31323
|
+
<changefreq>${isCurrentYear ? "weekly" : "monthly"}</changefreq>
|
|
31324
|
+
<priority>${(yearPriority - 0.1).toFixed(1)}</priority>
|
|
31299
31325
|
</url>
|
|
31300
31326
|
`;
|
|
31301
31327
|
}
|
|
@@ -31304,6 +31330,48 @@ ${rssItems}
|
|
|
31304
31330
|
sitemapContent += `</urlset>`;
|
|
31305
31331
|
await Bun.write(path5.join(this.options.outputDir, "sitemap.xml"), sitemapContent);
|
|
31306
31332
|
console.log("Generated sitemap.xml");
|
|
31333
|
+
const urlCount = this.site.posts.length + Object.keys(this.site.tags).length + 10;
|
|
31334
|
+
const sitemapSize = sitemapContent.length;
|
|
31335
|
+
if (urlCount > 1000 || sitemapSize > 40000) {
|
|
31336
|
+
await this.generateSitemapIndex();
|
|
31337
|
+
}
|
|
31338
|
+
}
|
|
31339
|
+
async generateSitemapIndex() {
|
|
31340
|
+
const currentDate = this.getPacificDate(new Date).toISOString();
|
|
31341
|
+
const config = this.options.config;
|
|
31342
|
+
let sitemapIndexContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
31343
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
31344
|
+
`;
|
|
31345
|
+
sitemapIndexContent += ` <sitemap>
|
|
31346
|
+
<loc>${config.baseUrl}/sitemap.xml</loc>
|
|
31347
|
+
<lastmod>${currentDate}</lastmod>
|
|
31348
|
+
</sitemap>
|
|
31349
|
+
`;
|
|
31350
|
+
sitemapIndexContent += `</sitemapindex>`;
|
|
31351
|
+
await Bun.write(path5.join(this.options.outputDir, "sitemap_index.xml"), sitemapIndexContent);
|
|
31352
|
+
console.log("Generated sitemap_index.xml");
|
|
31353
|
+
}
|
|
31354
|
+
async generateRobotsTxt() {
|
|
31355
|
+
const config = this.options.config;
|
|
31356
|
+
const robotsTxtContent = `# Robots.txt for ${config.domain}
|
|
31357
|
+
# Generated by Bunki
|
|
31358
|
+
|
|
31359
|
+
User-agent: *
|
|
31360
|
+
Allow: /
|
|
31361
|
+
|
|
31362
|
+
# Sitemaps
|
|
31363
|
+
Sitemap: ${config.baseUrl}/sitemap.xml
|
|
31364
|
+
|
|
31365
|
+
# Crawl-delay (optional, adjust as needed)
|
|
31366
|
+
# Crawl-delay: 1
|
|
31367
|
+
|
|
31368
|
+
# Disallow specific paths (uncomment as needed)
|
|
31369
|
+
# Disallow: /private/
|
|
31370
|
+
# Disallow: /admin/
|
|
31371
|
+
# Disallow: /api/
|
|
31372
|
+
`;
|
|
31373
|
+
await Bun.write(path5.join(this.options.outputDir, "robots.txt"), robotsTxtContent);
|
|
31374
|
+
console.log("Generated robots.txt");
|
|
31307
31375
|
}
|
|
31308
31376
|
}
|
|
31309
31377
|
// src/utils/image-uploader.ts
|
package/dist/site-generator.d.ts
CHANGED
package/package.json
CHANGED