bunki 0.9.1 → 0.10.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/dist/cli.js CHANGED
@@ -32764,6 +32764,18 @@ function escape(html, encode) {
32764
32764
 
32765
32765
  // src/utils/markdown-utils.ts
32766
32766
  var import_sanitize_html = __toESM(require_sanitize_html(), 1);
32767
+
32768
+ // src/utils/date-utils.ts
32769
+ function toPacificTime(date) {
32770
+ return new Date(new Date(date).toLocaleString("en-US", {
32771
+ timeZone: "America/Los_Angeles"
32772
+ }));
32773
+ }
32774
+ function getPacificYear(date) {
32775
+ return toPacificTime(date).getFullYear();
32776
+ }
32777
+
32778
+ // src/utils/markdown-utils.ts
32767
32779
  core_default.registerLanguage("javascript", javascript);
32768
32780
  core_default.registerLanguage("typescript", typescript);
32769
32781
  core_default.registerLanguage("markdown", markdown);
@@ -32918,10 +32930,8 @@ async function parseMarkdownFile(filePath) {
32918
32930
  }
32919
32931
  let slug = data.slug || getBaseFilename(filePath);
32920
32932
  const sanitizedHtml = convertMarkdownToHtml(content);
32921
- const pacificDate = new Date(new Date(data.date).toLocaleString("en-US", {
32922
- timeZone: "America/Los_Angeles"
32923
- }));
32924
- const postYear = pacificDate.getFullYear();
32933
+ const pacificDate = toPacificTime(data.date);
32934
+ const postYear = getPacificYear(data.date);
32925
32935
  const post = {
32926
32936
  title: data.title,
32927
32937
  date: pacificDate.toISOString(),
@@ -33179,15 +33189,18 @@ class SiteGenerator {
33179
33189
  options;
33180
33190
  site;
33181
33191
  formatRSSDate(date) {
33182
- const pacificDate = new Date(new Date(date).toLocaleString("en-US", {
33183
- timeZone: "America/Los_Angeles"
33184
- }));
33185
- return pacificDate.toUTCString();
33192
+ return toPacificTime(date).toUTCString();
33186
33193
  }
33187
- getPacificDate(date) {
33188
- return new Date(new Date(date).toLocaleString("en-US", {
33189
- timeZone: "America/Los_Angeles"
33190
- }));
33194
+ groupPostsByYear(posts) {
33195
+ const postsByYear = {};
33196
+ for (const post of posts) {
33197
+ const year = getPacificYear(post.date).toString();
33198
+ if (!postsByYear[year]) {
33199
+ postsByYear[year] = [];
33200
+ }
33201
+ postsByYear[year].push(post);
33202
+ }
33203
+ return postsByYear;
33191
33204
  }
33192
33205
  getSortedTags(limit) {
33193
33206
  const sorted = Object.values(this.site.tags).sort((a, b2) => b2.count - a.count);
@@ -33213,17 +33226,15 @@ class SiteGenerator {
33213
33226
  this.site = {
33214
33227
  name: options2.config.domain,
33215
33228
  posts: [],
33216
- tags: {}
33229
+ tags: {},
33230
+ postsByYear: {}
33217
33231
  };
33218
33232
  const env = import_nunjucks.default.configure(this.options.templatesDir, {
33219
33233
  autoescape: true,
33220
33234
  watch: false
33221
33235
  });
33222
33236
  env.addFilter("date", function(date, format) {
33223
- const pstDate = new Date(date).toLocaleString("en-US", {
33224
- timeZone: "America/Los_Angeles"
33225
- });
33226
- const d2 = new Date(pstDate);
33237
+ const d2 = toPacificTime(date);
33227
33238
  const months = [
33228
33239
  "January",
33229
33240
  "February",
@@ -33297,34 +33308,28 @@ class SiteGenerator {
33297
33308
  this.site = {
33298
33309
  name: this.options.config.domain,
33299
33310
  posts,
33300
- tags
33311
+ tags,
33312
+ postsByYear: this.groupPostsByYear(posts)
33301
33313
  };
33302
33314
  }
33303
33315
  async generate() {
33304
33316
  console.log("Generating static site...");
33305
33317
  await ensureDir(this.options.outputDir);
33306
33318
  await this.generateStylesheet();
33307
- await this.generateIndexPage();
33308
- await this.generatePostPages();
33309
- await this.generateTagPages();
33310
- await this.generateYearArchives();
33311
- await this.generateRSSFeed();
33312
- await this.generateSitemap();
33313
- await this.generateRobotsTxt();
33314
- await this.copyStaticAssets();
33319
+ await Promise.all([
33320
+ this.generateIndexPage(),
33321
+ this.generatePostPages(),
33322
+ this.generateTagPages(),
33323
+ this.generateYearArchives(),
33324
+ this.generateRSSFeed(),
33325
+ this.generateSitemap(),
33326
+ this.generateRobotsTxt(),
33327
+ this.copyStaticAssets()
33328
+ ]);
33315
33329
  console.log("Site generation complete!");
33316
33330
  }
33317
33331
  async generateYearArchives() {
33318
- const postsByYear = {};
33319
- for (const post of this.site.posts) {
33320
- const postDate = new Date(post.date);
33321
- const year = postDate.getFullYear().toString();
33322
- if (!postsByYear[year]) {
33323
- postsByYear[year] = [];
33324
- }
33325
- postsByYear[year].push(post);
33326
- }
33327
- for (const [year, yearPosts] of Object.entries(postsByYear)) {
33332
+ for (const [year, yearPosts] of Object.entries(this.site.postsByYear)) {
33328
33333
  const yearDir = path5.join(this.options.outputDir, year);
33329
33334
  await ensureDir(yearDir);
33330
33335
  const pageSize = 10;
@@ -33545,7 +33550,7 @@ class SiteGenerator {
33545
33550
  async generateRSSFeed() {
33546
33551
  const posts = this.site.posts.slice(0, 15);
33547
33552
  const config = this.options.config;
33548
- const now = this.getPacificDate(new Date);
33553
+ const now = toPacificTime(new Date);
33549
33554
  const latestPostDate = posts.length > 0 ? posts[0].date : now.toISOString();
33550
33555
  const lastBuildDate = this.formatRSSDate(latestPostDate);
33551
33556
  const rssItems = posts.map((post) => {
@@ -33619,10 +33624,10 @@ ${rssItems}
33619
33624
  await Bun.write(path5.join(this.options.outputDir, "feed.xml"), rssContent);
33620
33625
  }
33621
33626
  async generateSitemap() {
33622
- const currentDate = this.getPacificDate(new Date).toISOString();
33627
+ const currentDate = toPacificTime(new Date).toISOString();
33623
33628
  const pageSize = 10;
33624
33629
  const config = this.options.config;
33625
- const now = this.getPacificDate(new Date).getTime();
33630
+ const now = toPacificTime(new Date).getTime();
33626
33631
  const ONE_DAY = 24 * 60 * 60 * 1000;
33627
33632
  const ONE_WEEK = 7 * ONE_DAY;
33628
33633
  const ONE_MONTH = 30 * ONE_DAY;
@@ -33703,16 +33708,7 @@ ${rssItems}
33703
33708
  }
33704
33709
  }
33705
33710
  }
33706
- const postsByYear = {};
33707
- for (const post of this.site.posts) {
33708
- const postDate = new Date(post.date);
33709
- const year = postDate.getFullYear().toString();
33710
- if (!postsByYear[year]) {
33711
- postsByYear[year] = [];
33712
- }
33713
- postsByYear[year].push(post);
33714
- }
33715
- for (const [year, yearPosts] of Object.entries(postsByYear)) {
33711
+ for (const [year, yearPosts] of Object.entries(this.site.postsByYear)) {
33716
33712
  const currentYear = new Date().getFullYear();
33717
33713
  const isCurrentYear = parseInt(year) === currentYear;
33718
33714
  const yearPriority = isCurrentYear ? 0.7 : 0.5;
@@ -33746,7 +33742,7 @@ ${rssItems}
33746
33742
  }
33747
33743
  }
33748
33744
  async generateSitemapIndex() {
33749
- const currentDate = this.getPacificDate(new Date).toISOString();
33745
+ const currentDate = toPacificTime(new Date).toISOString();
33750
33746
  const config = this.options.config;
33751
33747
  let sitemapIndexContent = `<?xml version="1.0" encoding="UTF-8"?>
33752
33748
  <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@@ -34817,7 +34813,7 @@ registerServeCommand(program2);
34817
34813
  registerCssCommand(program2);
34818
34814
  registerImagesPushCommand(program2);
34819
34815
  registerValidateCommand(program2);
34820
- program2.name("bunki").description("An opinionated static site generator built with Bun").version("0.9.1");
34816
+ program2.name("bunki").description("An opinionated static site generator built with Bun").version("0.10.0");
34821
34817
  var currentFile = import.meta.url.replace("file://", "");
34822
34818
  var mainFile = Bun.main;
34823
34819
  if (currentFile === mainFile || currentFile.endsWith(mainFile)) {
package/dist/index.js CHANGED
@@ -30382,6 +30382,18 @@ function escape(html, encode) {
30382
30382
 
30383
30383
  // src/utils/markdown-utils.ts
30384
30384
  var import_sanitize_html = __toESM(require_sanitize_html(), 1);
30385
+
30386
+ // src/utils/date-utils.ts
30387
+ function toPacificTime(date) {
30388
+ return new Date(new Date(date).toLocaleString("en-US", {
30389
+ timeZone: "America/Los_Angeles"
30390
+ }));
30391
+ }
30392
+ function getPacificYear(date) {
30393
+ return toPacificTime(date).getFullYear();
30394
+ }
30395
+
30396
+ // src/utils/markdown-utils.ts
30385
30397
  core_default.registerLanguage("javascript", javascript);
30386
30398
  core_default.registerLanguage("typescript", typescript);
30387
30399
  core_default.registerLanguage("markdown", markdown);
@@ -30536,10 +30548,8 @@ async function parseMarkdownFile(filePath) {
30536
30548
  }
30537
30549
  let slug = data.slug || getBaseFilename(filePath);
30538
30550
  const sanitizedHtml = convertMarkdownToHtml(content);
30539
- const pacificDate = new Date(new Date(data.date).toLocaleString("en-US", {
30540
- timeZone: "America/Los_Angeles"
30541
- }));
30542
- const postYear = pacificDate.getFullYear();
30551
+ const pacificDate = toPacificTime(data.date);
30552
+ const postYear = getPacificYear(data.date);
30543
30553
  const post = {
30544
30554
  title: data.title,
30545
30555
  date: pacificDate.toISOString(),
@@ -31126,15 +31136,18 @@ class SiteGenerator {
31126
31136
  options;
31127
31137
  site;
31128
31138
  formatRSSDate(date) {
31129
- const pacificDate = new Date(new Date(date).toLocaleString("en-US", {
31130
- timeZone: "America/Los_Angeles"
31131
- }));
31132
- return pacificDate.toUTCString();
31139
+ return toPacificTime(date).toUTCString();
31133
31140
  }
31134
- getPacificDate(date) {
31135
- return new Date(new Date(date).toLocaleString("en-US", {
31136
- timeZone: "America/Los_Angeles"
31137
- }));
31141
+ groupPostsByYear(posts) {
31142
+ const postsByYear = {};
31143
+ for (const post of posts) {
31144
+ const year = getPacificYear(post.date).toString();
31145
+ if (!postsByYear[year]) {
31146
+ postsByYear[year] = [];
31147
+ }
31148
+ postsByYear[year].push(post);
31149
+ }
31150
+ return postsByYear;
31138
31151
  }
31139
31152
  getSortedTags(limit) {
31140
31153
  const sorted = Object.values(this.site.tags).sort((a, b2) => b2.count - a.count);
@@ -31160,17 +31173,15 @@ class SiteGenerator {
31160
31173
  this.site = {
31161
31174
  name: options2.config.domain,
31162
31175
  posts: [],
31163
- tags: {}
31176
+ tags: {},
31177
+ postsByYear: {}
31164
31178
  };
31165
31179
  const env = import_nunjucks.default.configure(this.options.templatesDir, {
31166
31180
  autoescape: true,
31167
31181
  watch: false
31168
31182
  });
31169
31183
  env.addFilter("date", function(date, format) {
31170
- const pstDate = new Date(date).toLocaleString("en-US", {
31171
- timeZone: "America/Los_Angeles"
31172
- });
31173
- const d2 = new Date(pstDate);
31184
+ const d2 = toPacificTime(date);
31174
31185
  const months = [
31175
31186
  "January",
31176
31187
  "February",
@@ -31244,34 +31255,28 @@ class SiteGenerator {
31244
31255
  this.site = {
31245
31256
  name: this.options.config.domain,
31246
31257
  posts,
31247
- tags
31258
+ tags,
31259
+ postsByYear: this.groupPostsByYear(posts)
31248
31260
  };
31249
31261
  }
31250
31262
  async generate() {
31251
31263
  console.log("Generating static site...");
31252
31264
  await ensureDir(this.options.outputDir);
31253
31265
  await this.generateStylesheet();
31254
- await this.generateIndexPage();
31255
- await this.generatePostPages();
31256
- await this.generateTagPages();
31257
- await this.generateYearArchives();
31258
- await this.generateRSSFeed();
31259
- await this.generateSitemap();
31260
- await this.generateRobotsTxt();
31261
- await this.copyStaticAssets();
31266
+ await Promise.all([
31267
+ this.generateIndexPage(),
31268
+ this.generatePostPages(),
31269
+ this.generateTagPages(),
31270
+ this.generateYearArchives(),
31271
+ this.generateRSSFeed(),
31272
+ this.generateSitemap(),
31273
+ this.generateRobotsTxt(),
31274
+ this.copyStaticAssets()
31275
+ ]);
31262
31276
  console.log("Site generation complete!");
31263
31277
  }
31264
31278
  async generateYearArchives() {
31265
- const postsByYear = {};
31266
- for (const post of this.site.posts) {
31267
- const postDate = new Date(post.date);
31268
- const year = postDate.getFullYear().toString();
31269
- if (!postsByYear[year]) {
31270
- postsByYear[year] = [];
31271
- }
31272
- postsByYear[year].push(post);
31273
- }
31274
- for (const [year, yearPosts] of Object.entries(postsByYear)) {
31279
+ for (const [year, yearPosts] of Object.entries(this.site.postsByYear)) {
31275
31280
  const yearDir = path5.join(this.options.outputDir, year);
31276
31281
  await ensureDir(yearDir);
31277
31282
  const pageSize = 10;
@@ -31492,7 +31497,7 @@ class SiteGenerator {
31492
31497
  async generateRSSFeed() {
31493
31498
  const posts = this.site.posts.slice(0, 15);
31494
31499
  const config = this.options.config;
31495
- const now = this.getPacificDate(new Date);
31500
+ const now = toPacificTime(new Date);
31496
31501
  const latestPostDate = posts.length > 0 ? posts[0].date : now.toISOString();
31497
31502
  const lastBuildDate = this.formatRSSDate(latestPostDate);
31498
31503
  const rssItems = posts.map((post) => {
@@ -31566,10 +31571,10 @@ ${rssItems}
31566
31571
  await Bun.write(path5.join(this.options.outputDir, "feed.xml"), rssContent);
31567
31572
  }
31568
31573
  async generateSitemap() {
31569
- const currentDate = this.getPacificDate(new Date).toISOString();
31574
+ const currentDate = toPacificTime(new Date).toISOString();
31570
31575
  const pageSize = 10;
31571
31576
  const config = this.options.config;
31572
- const now = this.getPacificDate(new Date).getTime();
31577
+ const now = toPacificTime(new Date).getTime();
31573
31578
  const ONE_DAY = 24 * 60 * 60 * 1000;
31574
31579
  const ONE_WEEK = 7 * ONE_DAY;
31575
31580
  const ONE_MONTH = 30 * ONE_DAY;
@@ -31650,16 +31655,7 @@ ${rssItems}
31650
31655
  }
31651
31656
  }
31652
31657
  }
31653
- const postsByYear = {};
31654
- for (const post of this.site.posts) {
31655
- const postDate = new Date(post.date);
31656
- const year = postDate.getFullYear().toString();
31657
- if (!postsByYear[year]) {
31658
- postsByYear[year] = [];
31659
- }
31660
- postsByYear[year].push(post);
31661
- }
31662
- for (const [year, yearPosts] of Object.entries(postsByYear)) {
31658
+ for (const [year, yearPosts] of Object.entries(this.site.postsByYear)) {
31663
31659
  const currentYear = new Date().getFullYear();
31664
31660
  const isCurrentYear = parseInt(year) === currentYear;
31665
31661
  const yearPriority = isCurrentYear ? 0.7 : 0.5;
@@ -31693,7 +31689,7 @@ ${rssItems}
31693
31689
  }
31694
31690
  }
31695
31691
  async generateSitemapIndex() {
31696
- const currentDate = this.getPacificDate(new Date).toISOString();
31692
+ const currentDate = toPacificTime(new Date).toISOString();
31697
31693
  const config = this.options.config;
31698
31694
  let sitemapIndexContent = `<?xml version="1.0" encoding="UTF-8"?>
31699
31695
  <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@@ -3,7 +3,7 @@ export declare class SiteGenerator {
3
3
  private options;
4
4
  private site;
5
5
  private formatRSSDate;
6
- private getPacificDate;
6
+ private groupPostsByYear;
7
7
  private getSortedTags;
8
8
  private createPagination;
9
9
  constructor(options: GeneratorOptions);
package/dist/types.d.ts CHANGED
@@ -134,6 +134,8 @@ export interface Site {
134
134
  posts: Post[];
135
135
  /** Map of tag names to tag data */
136
136
  tags: Record<string, TagData>;
137
+ /** Posts grouped by year for efficient year archive generation */
138
+ postsByYear: Record<string, Post[]>;
137
139
  }
138
140
  /**
139
141
  * Interface for uploaders (different services can implement this)
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Date utility functions for bunki
3
+ */
4
+ /**
5
+ * Converts a date to Pacific Time (America/Los_Angeles timezone)
6
+ * This is used consistently across the codebase for date handling
7
+ *
8
+ * @param date - Date string or Date object to convert
9
+ * @returns Date object in Pacific timezone
10
+ */
11
+ export declare function toPacificTime(date: string | Date): Date;
12
+ /**
13
+ * Gets the year from a date in Pacific timezone
14
+ *
15
+ * @param date - Date string or Date object
16
+ * @returns Year as number
17
+ */
18
+ export declare function getPacificYear(date: string | Date): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunki",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
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",