bunki 0.4.0 → 0.4.2

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/dist/cli.js CHANGED
@@ -32988,6 +32988,10 @@ class SiteGenerator {
32988
32988
  timeZone: "America/Los_Angeles"
32989
32989
  }));
32990
32990
  }
32991
+ getSortedTags(limit) {
32992
+ const sorted = Object.values(this.site.tags).sort((a, b2) => b2.count - a.count);
32993
+ return limit ? sorted.slice(0, limit) : sorted;
32994
+ }
32991
32995
  createPagination(items, currentPage, pageSize, pagePath) {
32992
32996
  const totalItems = items.length;
32993
32997
  const totalPages = Math.ceil(totalItems / pageSize);
@@ -33102,6 +33106,7 @@ class SiteGenerator {
33102
33106
  await this.generateYearArchives();
33103
33107
  await this.generateRSSFeed();
33104
33108
  await this.generateSitemap();
33109
+ await this.generateRobotsTxt();
33105
33110
  await this.copyStaticAssets();
33106
33111
  console.log("Site generation complete!");
33107
33112
  }
@@ -33128,7 +33133,7 @@ class SiteGenerator {
33128
33133
  const yearPageHtml = import_nunjucks.default.render("archive.njk", {
33129
33134
  site: this.options.config,
33130
33135
  posts: paginatedPosts,
33131
- tags: Object.values(this.site.tags),
33136
+ tags: this.getSortedTags(this.options.config.maxTagsOnHomepage),
33132
33137
  year,
33133
33138
  pagination
33134
33139
  });
@@ -33153,7 +33158,7 @@ class SiteGenerator {
33153
33158
  const pageHtml = import_nunjucks.default.render("index.njk", {
33154
33159
  site: this.options.config,
33155
33160
  posts: paginatedPosts,
33156
- tags: Object.values(this.site.tags),
33161
+ tags: this.getSortedTags(this.options.config.maxTagsOnHomepage),
33157
33162
  pagination
33158
33163
  });
33159
33164
  if (page === 1) {
@@ -33172,8 +33177,7 @@ class SiteGenerator {
33172
33177
  await ensureDir(postDir);
33173
33178
  const postHtml = import_nunjucks.default.render("post.njk", {
33174
33179
  site: this.options.config,
33175
- post,
33176
- tags: Object.values(this.site.tags)
33180
+ post
33177
33181
  });
33178
33182
  await Bun.write(path5.join(postDir, "index.html"), postHtml);
33179
33183
  }
@@ -33183,7 +33187,7 @@ class SiteGenerator {
33183
33187
  await ensureDir(tagsDir);
33184
33188
  const tagIndexHtml = import_nunjucks.default.render("tags.njk", {
33185
33189
  site: this.options.config,
33186
- tags: Object.values(this.site.tags)
33190
+ tags: this.getSortedTags()
33187
33191
  });
33188
33192
  await Bun.write(path5.join(tagsDir, "index.html"), tagIndexHtml);
33189
33193
  for (const [tagName, tagData] of Object.entries(this.site.tags)) {
@@ -33457,6 +33461,48 @@ ${rssItems}
33457
33461
  sitemapContent += `</urlset>`;
33458
33462
  await Bun.write(path5.join(this.options.outputDir, "sitemap.xml"), sitemapContent);
33459
33463
  console.log("Generated sitemap.xml");
33464
+ const urlCount = this.site.posts.length + Object.keys(this.site.tags).length + 10;
33465
+ const sitemapSize = sitemapContent.length;
33466
+ if (urlCount > 1000 || sitemapSize > 40000) {
33467
+ await this.generateSitemapIndex();
33468
+ }
33469
+ }
33470
+ async generateSitemapIndex() {
33471
+ const currentDate = this.getPacificDate(new Date).toISOString();
33472
+ const config = this.options.config;
33473
+ let sitemapIndexContent = `<?xml version="1.0" encoding="UTF-8"?>
33474
+ <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33475
+ `;
33476
+ sitemapIndexContent += ` <sitemap>
33477
+ <loc>${config.baseUrl}/sitemap.xml</loc>
33478
+ <lastmod>${currentDate}</lastmod>
33479
+ </sitemap>
33480
+ `;
33481
+ sitemapIndexContent += `</sitemapindex>`;
33482
+ await Bun.write(path5.join(this.options.outputDir, "sitemap_index.xml"), sitemapIndexContent);
33483
+ console.log("Generated sitemap_index.xml");
33484
+ }
33485
+ async generateRobotsTxt() {
33486
+ const config = this.options.config;
33487
+ const robotsTxtContent = `# Robots.txt for ${config.domain}
33488
+ # Generated by Bunki
33489
+
33490
+ User-agent: *
33491
+ Allow: /
33492
+
33493
+ # Sitemaps
33494
+ Sitemap: ${config.baseUrl}/sitemap.xml
33495
+
33496
+ # Crawl-delay (optional, adjust as needed)
33497
+ # Crawl-delay: 1
33498
+
33499
+ # Disallow specific paths (uncomment as needed)
33500
+ # Disallow: /private/
33501
+ # Disallow: /admin/
33502
+ # Disallow: /api/
33503
+ `;
33504
+ await Bun.write(path5.join(this.options.outputDir, "robots.txt"), robotsTxtContent);
33505
+ console.log("Generated robots.txt");
33460
33506
  }
33461
33507
  }
33462
33508
 
package/dist/index.js CHANGED
@@ -30860,6 +30860,10 @@ class SiteGenerator {
30860
30860
  timeZone: "America/Los_Angeles"
30861
30861
  }));
30862
30862
  }
30863
+ getSortedTags(limit) {
30864
+ const sorted = Object.values(this.site.tags).sort((a, b2) => b2.count - a.count);
30865
+ return limit ? sorted.slice(0, limit) : sorted;
30866
+ }
30863
30867
  createPagination(items, currentPage, pageSize, pagePath) {
30864
30868
  const totalItems = items.length;
30865
30869
  const totalPages = Math.ceil(totalItems / pageSize);
@@ -30974,6 +30978,7 @@ class SiteGenerator {
30974
30978
  await this.generateYearArchives();
30975
30979
  await this.generateRSSFeed();
30976
30980
  await this.generateSitemap();
30981
+ await this.generateRobotsTxt();
30977
30982
  await this.copyStaticAssets();
30978
30983
  console.log("Site generation complete!");
30979
30984
  }
@@ -31000,7 +31005,7 @@ class SiteGenerator {
31000
31005
  const yearPageHtml = import_nunjucks.default.render("archive.njk", {
31001
31006
  site: this.options.config,
31002
31007
  posts: paginatedPosts,
31003
- tags: Object.values(this.site.tags),
31008
+ tags: this.getSortedTags(this.options.config.maxTagsOnHomepage),
31004
31009
  year,
31005
31010
  pagination
31006
31011
  });
@@ -31025,7 +31030,7 @@ class SiteGenerator {
31025
31030
  const pageHtml = import_nunjucks.default.render("index.njk", {
31026
31031
  site: this.options.config,
31027
31032
  posts: paginatedPosts,
31028
- tags: Object.values(this.site.tags),
31033
+ tags: this.getSortedTags(this.options.config.maxTagsOnHomepage),
31029
31034
  pagination
31030
31035
  });
31031
31036
  if (page === 1) {
@@ -31044,8 +31049,7 @@ class SiteGenerator {
31044
31049
  await ensureDir(postDir);
31045
31050
  const postHtml = import_nunjucks.default.render("post.njk", {
31046
31051
  site: this.options.config,
31047
- post,
31048
- tags: Object.values(this.site.tags)
31052
+ post
31049
31053
  });
31050
31054
  await Bun.write(path5.join(postDir, "index.html"), postHtml);
31051
31055
  }
@@ -31055,7 +31059,7 @@ class SiteGenerator {
31055
31059
  await ensureDir(tagsDir);
31056
31060
  const tagIndexHtml = import_nunjucks.default.render("tags.njk", {
31057
31061
  site: this.options.config,
31058
- tags: Object.values(this.site.tags)
31062
+ tags: this.getSortedTags()
31059
31063
  });
31060
31064
  await Bun.write(path5.join(tagsDir, "index.html"), tagIndexHtml);
31061
31065
  for (const [tagName, tagData] of Object.entries(this.site.tags)) {
@@ -31329,6 +31333,48 @@ ${rssItems}
31329
31333
  sitemapContent += `</urlset>`;
31330
31334
  await Bun.write(path5.join(this.options.outputDir, "sitemap.xml"), sitemapContent);
31331
31335
  console.log("Generated sitemap.xml");
31336
+ const urlCount = this.site.posts.length + Object.keys(this.site.tags).length + 10;
31337
+ const sitemapSize = sitemapContent.length;
31338
+ if (urlCount > 1000 || sitemapSize > 40000) {
31339
+ await this.generateSitemapIndex();
31340
+ }
31341
+ }
31342
+ async generateSitemapIndex() {
31343
+ const currentDate = this.getPacificDate(new Date).toISOString();
31344
+ const config = this.options.config;
31345
+ let sitemapIndexContent = `<?xml version="1.0" encoding="UTF-8"?>
31346
+ <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
31347
+ `;
31348
+ sitemapIndexContent += ` <sitemap>
31349
+ <loc>${config.baseUrl}/sitemap.xml</loc>
31350
+ <lastmod>${currentDate}</lastmod>
31351
+ </sitemap>
31352
+ `;
31353
+ sitemapIndexContent += `</sitemapindex>`;
31354
+ await Bun.write(path5.join(this.options.outputDir, "sitemap_index.xml"), sitemapIndexContent);
31355
+ console.log("Generated sitemap_index.xml");
31356
+ }
31357
+ async generateRobotsTxt() {
31358
+ const config = this.options.config;
31359
+ const robotsTxtContent = `# Robots.txt for ${config.domain}
31360
+ # Generated by Bunki
31361
+
31362
+ User-agent: *
31363
+ Allow: /
31364
+
31365
+ # Sitemaps
31366
+ Sitemap: ${config.baseUrl}/sitemap.xml
31367
+
31368
+ # Crawl-delay (optional, adjust as needed)
31369
+ # Crawl-delay: 1
31370
+
31371
+ # Disallow specific paths (uncomment as needed)
31372
+ # Disallow: /private/
31373
+ # Disallow: /admin/
31374
+ # Disallow: /api/
31375
+ `;
31376
+ await Bun.write(path5.join(this.options.outputDir, "robots.txt"), robotsTxtContent);
31377
+ console.log("Generated robots.txt");
31332
31378
  }
31333
31379
  }
31334
31380
  // src/utils/image-uploader.ts
@@ -4,6 +4,7 @@ export declare class SiteGenerator {
4
4
  private site;
5
5
  private formatRSSDate;
6
6
  private getPacificDate;
7
+ private getSortedTags;
7
8
  private createPagination;
8
9
  constructor(options: GeneratorOptions);
9
10
  initialize(): Promise<void>;
@@ -17,4 +18,6 @@ export declare class SiteGenerator {
17
18
  private copyStaticAssets;
18
19
  private generateRSSFeed;
19
20
  private generateSitemap;
21
+ private generateSitemapIndex;
22
+ private generateRobotsTxt;
20
23
  }
package/dist/types.d.ts CHANGED
@@ -54,6 +54,8 @@ export interface SiteConfig {
54
54
  s3?: S3Config;
55
55
  /** CSS processing configuration */
56
56
  css?: CSSConfig;
57
+ /** Optional number of tags to display on homepage (sorted by count). If not set, all tags are shown */
58
+ maxTagsOnHomepage?: number;
57
59
  /** Additional custom configuration options */
58
60
  [key: string]: any;
59
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunki",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "An opinionated static site generator built with Bun featuring PostCSS integration and modern web development workflows",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",