bunki 0.3.8 → 0.4.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/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"],
@@ -33281,7 +33282,9 @@ class SiteGenerator {
33281
33282
  }
33282
33283
  if (await dirExists(publicDir)) {
33283
33284
  const copyRecursive = async (srcDir) => {
33284
- const entries = await fs3.promises.readdir(srcDir, { withFileTypes: true });
33285
+ const entries = await fs3.promises.readdir(srcDir, {
33286
+ withFileTypes: true
33287
+ });
33285
33288
  for (const entry of entries) {
33286
33289
  const srcPath = path5.join(srcDir, entry.name);
33287
33290
  const relativePath = path5.relative(publicDir, srcPath);
@@ -33337,6 +33340,20 @@ ${rssItems}
33337
33340
  const currentDate = this.getPacificDate(new Date).toISOString();
33338
33341
  const pageSize = 10;
33339
33342
  const config = this.options.config;
33343
+ const now = this.getPacificDate(new Date).getTime();
33344
+ const ONE_DAY = 24 * 60 * 60 * 1000;
33345
+ const ONE_WEEK = 7 * ONE_DAY;
33346
+ const ONE_MONTH = 30 * ONE_DAY;
33347
+ const calculatePriority = (date, basePriority) => {
33348
+ const postTime = new Date(date).getTime();
33349
+ const age = now - postTime;
33350
+ if (age < ONE_WEEK) {
33351
+ return Math.min(1, basePriority + 0.2);
33352
+ } else if (age < ONE_MONTH) {
33353
+ return Math.min(1, basePriority + 0.1);
33354
+ }
33355
+ return basePriority;
33356
+ };
33340
33357
  let sitemapContent = `<?xml version="1.0" encoding="UTF-8"?>
33341
33358
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33342
33359
  `;
@@ -33354,7 +33371,7 @@ ${rssItems}
33354
33371
  <loc>${config.baseUrl}/page/${page}/</loc>
33355
33372
  <lastmod>${currentDate}</lastmod>
33356
33373
  <changefreq>daily</changefreq>
33357
- <priority>0.9</priority>
33374
+ <priority>0.8</priority>
33358
33375
  </url>
33359
33376
  `;
33360
33377
  }
@@ -33362,11 +33379,14 @@ ${rssItems}
33362
33379
  for (const post of this.site.posts) {
33363
33380
  const postUrl = `${config.baseUrl}${post.url}`;
33364
33381
  const postDate = new Date(post.date).toISOString();
33382
+ const priority = calculatePriority(post.date, 0.7);
33383
+ const age = now - new Date(post.date).getTime();
33384
+ const changefreq = age < ONE_MONTH ? "weekly" : "monthly";
33365
33385
  sitemapContent += ` <url>
33366
33386
  <loc>${postUrl}</loc>
33367
33387
  <lastmod>${postDate}</lastmod>
33368
- <changefreq>monthly</changefreq>
33369
- <priority>0.8</priority>
33388
+ <changefreq>${changefreq}</changefreq>
33389
+ <priority>${priority.toFixed(1)}</priority>
33370
33390
  </url>
33371
33391
  `;
33372
33392
  }
@@ -33374,16 +33394,18 @@ ${rssItems}
33374
33394
  <loc>${config.baseUrl}/tags/</loc>
33375
33395
  <lastmod>${currentDate}</lastmod>
33376
33396
  <changefreq>weekly</changefreq>
33377
- <priority>0.6</priority>
33397
+ <priority>0.5</priority>
33378
33398
  </url>
33379
33399
  `;
33380
33400
  for (const [, tagData] of Object.entries(this.site.tags)) {
33381
33401
  const tagUrl = `${config.baseUrl}/tags/${tagData.slug}/`;
33402
+ const mostRecentPost = tagData.posts[0];
33403
+ const tagPriority = mostRecentPost ? calculatePriority(mostRecentPost.date, 0.4) : 0.4;
33382
33404
  sitemapContent += ` <url>
33383
33405
  <loc>${tagUrl}</loc>
33384
33406
  <lastmod>${currentDate}</lastmod>
33385
33407
  <changefreq>weekly</changefreq>
33386
- <priority>0.5</priority>
33408
+ <priority>${tagPriority.toFixed(1)}</priority>
33387
33409
  </url>
33388
33410
  `;
33389
33411
  const totalTagPages = Math.ceil(tagData.posts.length / pageSize);
@@ -33393,7 +33415,7 @@ ${rssItems}
33393
33415
  <loc>${config.baseUrl}/tags/${tagData.slug}/page/${page}/</loc>
33394
33416
  <lastmod>${currentDate}</lastmod>
33395
33417
  <changefreq>weekly</changefreq>
33396
- <priority>0.5</priority>
33418
+ <priority>${Math.max(0.3, tagPriority - 0.1).toFixed(1)}</priority>
33397
33419
  </url>
33398
33420
  `;
33399
33421
  }
@@ -33409,11 +33431,14 @@ ${rssItems}
33409
33431
  postsByYear[year].push(post);
33410
33432
  }
33411
33433
  for (const [year, yearPosts] of Object.entries(postsByYear)) {
33434
+ const currentYear = new Date().getFullYear();
33435
+ const isCurrentYear = parseInt(year) === currentYear;
33436
+ const yearPriority = isCurrentYear ? 0.7 : 0.5;
33412
33437
  sitemapContent += ` <url>
33413
33438
  <loc>${config.baseUrl}/${year}/</loc>
33414
33439
  <lastmod>${currentDate}</lastmod>
33415
- <changefreq>monthly</changefreq>
33416
- <priority>0.6</priority>
33440
+ <changefreq>${isCurrentYear ? "weekly" : "monthly"}</changefreq>
33441
+ <priority>${yearPriority.toFixed(1)}</priority>
33417
33442
  </url>
33418
33443
  `;
33419
33444
  const totalYearPages = Math.ceil(yearPosts.length / pageSize);
@@ -33422,8 +33447,8 @@ ${rssItems}
33422
33447
  sitemapContent += ` <url>
33423
33448
  <loc>${config.baseUrl}/${year}/page/${page}/</loc>
33424
33449
  <lastmod>${currentDate}</lastmod>
33425
- <changefreq>monthly</changefreq>
33426
- <priority>0.6</priority>
33450
+ <changefreq>${isCurrentYear ? "weekly" : "monthly"}</changefreq>
33451
+ <priority>${(yearPriority - 0.1).toFixed(1)}</priority>
33427
33452
  </url>
33428
33453
  `;
33429
33454
  }
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"],
@@ -31153,7 +31154,9 @@ class SiteGenerator {
31153
31154
  }
31154
31155
  if (await dirExists(publicDir)) {
31155
31156
  const copyRecursive = async (srcDir) => {
31156
- const entries = await fs3.promises.readdir(srcDir, { withFileTypes: true });
31157
+ const entries = await fs3.promises.readdir(srcDir, {
31158
+ withFileTypes: true
31159
+ });
31157
31160
  for (const entry of entries) {
31158
31161
  const srcPath = path5.join(srcDir, entry.name);
31159
31162
  const relativePath = path5.relative(publicDir, srcPath);
@@ -31209,6 +31212,20 @@ ${rssItems}
31209
31212
  const currentDate = this.getPacificDate(new Date).toISOString();
31210
31213
  const pageSize = 10;
31211
31214
  const config = this.options.config;
31215
+ const now = this.getPacificDate(new Date).getTime();
31216
+ const ONE_DAY = 24 * 60 * 60 * 1000;
31217
+ const ONE_WEEK = 7 * ONE_DAY;
31218
+ const ONE_MONTH = 30 * ONE_DAY;
31219
+ const calculatePriority = (date, basePriority) => {
31220
+ const postTime = new Date(date).getTime();
31221
+ const age = now - postTime;
31222
+ if (age < ONE_WEEK) {
31223
+ return Math.min(1, basePriority + 0.2);
31224
+ } else if (age < ONE_MONTH) {
31225
+ return Math.min(1, basePriority + 0.1);
31226
+ }
31227
+ return basePriority;
31228
+ };
31212
31229
  let sitemapContent = `<?xml version="1.0" encoding="UTF-8"?>
31213
31230
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
31214
31231
  `;
@@ -31226,7 +31243,7 @@ ${rssItems}
31226
31243
  <loc>${config.baseUrl}/page/${page}/</loc>
31227
31244
  <lastmod>${currentDate}</lastmod>
31228
31245
  <changefreq>daily</changefreq>
31229
- <priority>0.9</priority>
31246
+ <priority>0.8</priority>
31230
31247
  </url>
31231
31248
  `;
31232
31249
  }
@@ -31234,11 +31251,14 @@ ${rssItems}
31234
31251
  for (const post of this.site.posts) {
31235
31252
  const postUrl = `${config.baseUrl}${post.url}`;
31236
31253
  const postDate = new Date(post.date).toISOString();
31254
+ const priority = calculatePriority(post.date, 0.7);
31255
+ const age = now - new Date(post.date).getTime();
31256
+ const changefreq = age < ONE_MONTH ? "weekly" : "monthly";
31237
31257
  sitemapContent += ` <url>
31238
31258
  <loc>${postUrl}</loc>
31239
31259
  <lastmod>${postDate}</lastmod>
31240
- <changefreq>monthly</changefreq>
31241
- <priority>0.8</priority>
31260
+ <changefreq>${changefreq}</changefreq>
31261
+ <priority>${priority.toFixed(1)}</priority>
31242
31262
  </url>
31243
31263
  `;
31244
31264
  }
@@ -31246,16 +31266,18 @@ ${rssItems}
31246
31266
  <loc>${config.baseUrl}/tags/</loc>
31247
31267
  <lastmod>${currentDate}</lastmod>
31248
31268
  <changefreq>weekly</changefreq>
31249
- <priority>0.6</priority>
31269
+ <priority>0.5</priority>
31250
31270
  </url>
31251
31271
  `;
31252
31272
  for (const [, tagData] of Object.entries(this.site.tags)) {
31253
31273
  const tagUrl = `${config.baseUrl}/tags/${tagData.slug}/`;
31274
+ const mostRecentPost = tagData.posts[0];
31275
+ const tagPriority = mostRecentPost ? calculatePriority(mostRecentPost.date, 0.4) : 0.4;
31254
31276
  sitemapContent += ` <url>
31255
31277
  <loc>${tagUrl}</loc>
31256
31278
  <lastmod>${currentDate}</lastmod>
31257
31279
  <changefreq>weekly</changefreq>
31258
- <priority>0.5</priority>
31280
+ <priority>${tagPriority.toFixed(1)}</priority>
31259
31281
  </url>
31260
31282
  `;
31261
31283
  const totalTagPages = Math.ceil(tagData.posts.length / pageSize);
@@ -31265,7 +31287,7 @@ ${rssItems}
31265
31287
  <loc>${config.baseUrl}/tags/${tagData.slug}/page/${page}/</loc>
31266
31288
  <lastmod>${currentDate}</lastmod>
31267
31289
  <changefreq>weekly</changefreq>
31268
- <priority>0.5</priority>
31290
+ <priority>${Math.max(0.3, tagPriority - 0.1).toFixed(1)}</priority>
31269
31291
  </url>
31270
31292
  `;
31271
31293
  }
@@ -31281,11 +31303,14 @@ ${rssItems}
31281
31303
  postsByYear[year].push(post);
31282
31304
  }
31283
31305
  for (const [year, yearPosts] of Object.entries(postsByYear)) {
31306
+ const currentYear = new Date().getFullYear();
31307
+ const isCurrentYear = parseInt(year) === currentYear;
31308
+ const yearPriority = isCurrentYear ? 0.7 : 0.5;
31284
31309
  sitemapContent += ` <url>
31285
31310
  <loc>${config.baseUrl}/${year}/</loc>
31286
31311
  <lastmod>${currentDate}</lastmod>
31287
- <changefreq>monthly</changefreq>
31288
- <priority>0.6</priority>
31312
+ <changefreq>${isCurrentYear ? "weekly" : "monthly"}</changefreq>
31313
+ <priority>${yearPriority.toFixed(1)}</priority>
31289
31314
  </url>
31290
31315
  `;
31291
31316
  const totalYearPages = Math.ceil(yearPosts.length / pageSize);
@@ -31294,8 +31319,8 @@ ${rssItems}
31294
31319
  sitemapContent += ` <url>
31295
31320
  <loc>${config.baseUrl}/${year}/page/${page}/</loc>
31296
31321
  <lastmod>${currentDate}</lastmod>
31297
- <changefreq>monthly</changefreq>
31298
- <priority>0.6</priority>
31322
+ <changefreq>${isCurrentYear ? "weekly" : "monthly"}</changefreq>
31323
+ <priority>${(yearPriority - 0.1).toFixed(1)}</priority>
31299
31324
  </url>
31300
31325
  `;
31301
31326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunki",
3
- "version": "0.3.8",
3
+ "version": "0.4.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",