single.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. {{ define "main" }}
  2. <div class="container-fluid blog_article p-0">
  3. <section class="bhouseweb_loc_banner">
  4. <img src="/img/banner/bn_blog@2x.webp" class="banner-img card-img" alt="...">
  5. </section>
  6. <div class="content">
  7. <h1>{{ .Title }}</h1>
  8. <div class="d-flex justify-content-between align-items-center">
  9. <span>{{ .PublishDate.Format "2006-01-02" }}</span>
  10. <div class="icon-box">
  11. <!-- 網址動態載入 -->
  12. <a href="" id="collection_icon_fb" target="_blank"><img src="/img/icon_fb@2x.png" alt=""></a>
  13. <a href="" id="collection_icon_line" target="_blank"><img src="/img/icon_line@2x.png" alt=""></a>
  14. </div>
  15. </div>
  16. <span class="line"></span>
  17. <p>{{ .Params.introduction | safeHTML }}</p>
  18. <br>
  19. <div class="question-box">
  20. <div>
  21. <p>
  22. 本文目錄
  23. <!-- {{ .Params.question_box_intro }} -->
  24. </p>
  25. {{ .TableOfContents }}
  26. </div>
  27. </div>
  28. <div class="blog-content">
  29. {{ .Content }}
  30. </div>
  31. <div class="d-flex justify-content-between link-box">
  32. <div class="d-flex flex-wrap align-items-center link-list">
  33. <p class="m-0">相關標籤:</p>
  34. <span>
  35. {{ range .Params.blog_tag }}
  36. <a href="/blog?tags={{ . }}">{{ . }}</a>
  37. </span>
  38. {{ end }}
  39. </div>
  40. <div class="icon-box">
  41. <a href="" id="collection_icon_fb" target="_blank"><img src="/img/icon_fb@2x.png" alt=""></a>
  42. <a href="" id="collection_icon_line" target="_blank"><img src="/img/icon_line@2x.png" alt=""></a>
  43. </div>
  44. </div>
  45. <a class="nav-link" onclick="previousPage()">
  46. <p class="readMore text-center">
  47. <span style="font-size: 18px;" class="fw-normal me-2">&lt;</span>回到成家知識庫
  48. </p>
  49. </a>
  50. <ul class="read-more-list"></ul>
  51. <!-- <ul class="read-more-list">
  52. <li>你可能會喜歡的,延伸閱讀點擊標題,看更多設計專欄!</li>
  53. <li><a href="">【居家風格】 60萬以下 ↓ 超有氛圍的成家夢想</a></li>
  54. <li><a href="">【認識裝潢裝修】 模組系統櫃板材等級挑選5攻略</a></li>
  55. <li><a href="">【認識裝潢裝修】 11-20坪 小坪數裝潢裝修,規劃師教你小宅打造大空間</a></li>
  56. <li><a href="">【認識裝潢裝修】 什麼是輕裝修?輕裝修的定義是什麼?輕裝修包含什麼呢?</a></li>
  57. <li><a href="">【規劃師服務】 什麼是規劃師?連室內設計師都推薦的「規劃師服務」</a></li>
  58. </ul> -->
  59. </div>
  60. </div>
  61. </div>
  62. <script>
  63. function previousPage() {
  64. history.back();
  65. }
  66. (function getContentsData() {
  67. // 線上版網址 https://bhouse3.ptt.cx:9002/api/
  68. // 本地端網址 http://localhost:9001/api/
  69. fetch('http://localhost:9001/api/contents?url=/blog').then(res => res.json()).then(list => {
  70. let title = document.querySelector('h1').innerHTML;
  71. let arr = [];
  72. list.map(e => {
  73. // 找出符合標題的文章
  74. if (e.meta_title.includes(title)) {
  75. let ttlList = JSON.parse(e.readmore_ttl.replace("\/", ""));
  76. let lnkList = JSON.parse(e.readmore_lnk.replace("\/", ""));
  77. let content = [
  78. '<li>你可能會喜歡的,延伸閱讀點擊標題,看更多設計專欄!</li>',
  79. ];
  80. for (let i = 0; i < ttlList.length; i++) {
  81. let obj =
  82. {
  83. ttl: ttlList[i],
  84. lnk: lnkList[i]
  85. };
  86. arr.push(obj);
  87. }
  88. for (let i = 0; i < arr.length; i++) {
  89. const item = arr[i];
  90. if (item.ttl !== "") {
  91. let dom = `
  92. <li>
  93. <a href="${item.lnk}">${item.ttl}</a>
  94. </li>`;
  95. content.push(dom);
  96. }
  97. }
  98. document.querySelector('.read-more-list').innerHTML = content.join(" ");
  99. let moreList = document.querySelector('.read-more-list');
  100. if (moreList.children.length === 1) {
  101. moreList.style.display = 'none';
  102. }
  103. }
  104. });
  105. })
  106. })();
  107. let contentList = document.getElementById("TableOfContents").getElementsByTagName("li");
  108. for (let i = 0; i < contentList.length; i++) {
  109. const element = contentList[i];
  110. if (element.childNodes.length == 0) {
  111. element.style.display = 'none';
  112. }
  113. }
  114. // let moreList = document.querySelector('.read-more-list');
  115. // if (moreList.children.length === 1) {
  116. // moreList.style.display = 'none';
  117. // }
  118. </script>
  119. {{ end }}