_config.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import lume from "lume/mod.ts";
  2. import base_path from "lume/plugins/base_path.ts";
  3. import code_highlight from "lume/plugins/code_highlight.ts";
  4. import date from "lume/plugins/date.ts";
  5. import id from "https://deno.land/x/date_fns/locale/id/index.js";
  6. import inline from "lume/plugins/inline.ts";
  7. import minify from "https://raw.githubusercontent.com/lumeland/experimental-plugins/main/minify/minify.ts"
  8. const site = lume({
  9. src: "_src",
  10. dest: "_site",
  11. prettyUrls: true,
  12. location: new URL("https://kusaeni.com"),
  13. server: {
  14. port: 3003,
  15. page404: "/404.html",
  16. open: false
  17. }
  18. });
  19. site.use(base_path())
  20. .use(code_highlight())
  21. .use(inline())
  22. .use(date({
  23. formats: {
  24. "POST": "dd MMM yy"
  25. },
  26. locales: {
  27. id
  28. }
  29. }))
  30. .use(minify({
  31. extensions: [".css", ".html", ".js"],
  32. htmlOptions: {
  33. minifyCSS: true,
  34. minifyJS: true
  35. }
  36. }))
  37. .copy("assets")
  38. .copy("404.html")
  39. .loadAssets([".css"])
  40. .helper('relasi', function (desc, coverImg, title, penulis, url) {
  41. let coverUrl = "https://ik.imagekit.io/hjse9uhdjqd/tr:n-cover/buku/";
  42. return `<div class="relasi m-auto">
  43. <img class="relaimg" src="${coverUrl}${coverImg}">
  44. <div class="relasi_meta">
  45. <div class="juduldkk">
  46. <h4><a class="hRelasi" href="${url}">${title}</a></h4>
  47. <span class="author">${penulis}</span>
  48. </div>
  49. <p>${desc}</p>
  50. </div>
  51. </div>`
  52. }, {
  53. body: "true",
  54. type: "tag"
  55. })
  56. .helper('terkait', function (desc: string, title: string, url: string) {
  57. return `<div class="terkait">
  58. <span class="ter">Artikel Terkait</span>
  59. <div class="kait">
  60. <h4><a class="hRelasi" href="${url}">${title}</a></h4>
  61. <p>${desc}</p>
  62. </div>
  63. </div>`;
  64. }, {
  65. body: 'true',
  66. type: "tag"
  67. })
  68. .process([".html"], (page: string) => {
  69. page.document.querySelectorAll("img").forEach((img) => {
  70. if (!img.hasAttribute("loading")) {
  71. img.setAttribute("loading", "lazy");
  72. }
  73. })
  74. })
  75. .preprocess([".html"],
  76. (page) => (page.data.year = page.data.date.getFullYear())
  77. );
  78. export default site;