single.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. <nav aria-label="breadcrumb">
  8. <ol class="breadcrumb mb-4">
  9. <li class="breadcrumb-item">
  10. <a href="/">
  11. <img src="/img/bt_footer_index@2x.png" style="width: 30px; margin: 0 0 5px;" alt="logo">
  12. </a>
  13. </li>
  14. <li class="breadcrumb-item">
  15. <a href="/blog_main/">成家知識專欄</a>
  16. </li>
  17. <li class="breadcrumb-item active" aria-current="page" id="category_name">{{ .Title }}</li>
  18. </ol>
  19. </nav>
  20. <h1>{{ .Title }}</h1>
  21. <div class="d-flex justify-content-between align-items-center">
  22. <span>{{ .PublishDate.Format "2006-01-02" }}</span>
  23. <div class="icon-box">
  24. <!-- 網址動態載入 -->
  25. <a href="" id="collection_icon_fb" target="_blank"><img src="/img/icon_fb@2x.png" alt=""></a>
  26. <a href="" id="collection_icon_line" target="_blank"><img src="/img/icon_line@2x.png" alt=""></a>
  27. </div>
  28. </div>
  29. <span class="line"></span>
  30. <p>{{ .Params.introduction | safeHTML }}</p>
  31. <br>
  32. <div class="question-box">
  33. <div>
  34. <p>
  35. 本文目錄
  36. <!-- {{ .Params.question_box_intro }} -->
  37. </p>
  38. {{ .TableOfContents }}
  39. </div>
  40. </div>
  41. <div class="blog-content">
  42. {{ .Content }}
  43. </div>
  44. <div class="d-flex justify-content-between link-box">
  45. <div class="d-flex flex-wrap align-items-center link-list">
  46. <p class="m-0">相關標籤:</p>
  47. <span>
  48. {{ range .Params.blog_tag }}
  49. <a href="/blog?tags={{ . }}">{{ . }}</a>
  50. </span>
  51. {{ end }}
  52. </div>
  53. <div class="icon-box">
  54. <a href="" id="collection_icon_fb" target="_blank"><img src="/img/icon_fb@2x.png" alt=""></a>
  55. <a href="" id="collection_icon_line" target="_blank"><img src="/img/icon_line@2x.png" alt=""></a>
  56. </div>
  57. </div>
  58. <a class="nav-link" onclick="previousPage()">
  59. <p class="readMore text-center">
  60. <span style="font-size: 18px;" class="fw-normal me-2">&lt;</span>回到成家知識庫
  61. </p>
  62. </a>
  63. <ul class="read-more-list"></ul>
  64. <!-- <ul class="read-more-list">
  65. <li>你可能會喜歡的,延伸閱讀點擊標題,看更多設計專欄!</li>
  66. <li><a href="">【居家風格】 60萬以下 ↓ 超有氛圍的成家夢想</a></li>
  67. <li><a href="">【認識裝潢裝修】 模組系統櫃板材等級挑選5攻略</a></li>
  68. <li><a href="">【認識裝潢裝修】 11-20坪 小坪數裝潢裝修,規劃師教你小宅打造大空間</a></li>
  69. <li><a href="">【認識裝潢裝修】 什麼是輕裝修?輕裝修的定義是什麼?輕裝修包含什麼呢?</a></li>
  70. <li><a href="">【規劃師服務】 什麼是規劃師?連室內設計師都推薦的「規劃師服務」</a></li>
  71. </ul> -->
  72. </div>
  73. </div>
  74. </div>
  75. <script>
  76. function previousPage() {
  77. history.back();
  78. }
  79. // 延伸閱讀清單
  80. (function getContentsData() {
  81. // 線上版網址 https://bhouse3.ptt.cx:9002/api/
  82. // 本地端網址 http://localhost:9001/api/
  83. fetch('https://bhouse3.ptt.cx:9002/api/contents?url=/blog').then(res => res.json()).then(list => {
  84. let title = document.querySelector('h1').innerHTML;
  85. let lnkList = [];
  86. // console.log('list', list);
  87. list.map(e => {
  88. // 找出符合標題的文章
  89. if (`${e.url}\/` === window.location.pathname) {
  90. lnkList = JSON.parse(e.readmore_lnk);
  91. // let ttlList = JSON.parse(e.readmore_ttl.replace("\/", ""));
  92. }
  93. });
  94. let content = [
  95. '<li>你可能會喜歡的,延伸閱讀點擊標題,看更多設計專欄!</li>',
  96. ];
  97. list.map(item => {
  98. for (let i = 0; i < lnkList.length; i++) {
  99. const link = lnkList[i];
  100. if (link == `${item.url}\/`) {
  101. /* 分類英文名稱 :
  102. 預售屋客變 pre-sale-house-design-change
  103. 驗收交屋 house-acceptance-check
  104. 預算準備 budget-planning
  105. 認識裝修裝潢 about-interior-decoration
  106. 空間計畫 floor-planning
  107. 居家風格 decoration-style
  108. 家具家電 furnitures-appliances
  109. 驗收入住 design-acceptanc-and-move-in */
  110. let categorieZh = "";
  111. if (item.categories.includes("pre-sale-house-design-change")) {
  112. categorieZh = "預售屋客變";
  113. } else if (item.categories.includes("house-acceptance-check")) {
  114. categorieZh = "驗收交屋";
  115. } else if (item.categories.includes("budget-planning")) {
  116. categorieZh = "預算準備";
  117. } else if (item.categories.includes("about-interior-decoration")) {
  118. categorieZh = "認識裝修裝潢";
  119. } else if (item.categories.includes("floor-planning")) {
  120. categorieZh = "空間計畫";
  121. } else if (item.categories.includes("decoration-style")) {
  122. categorieZh = "居家風格";
  123. } else if (item.categories.includes("furnitures-appliances")) {
  124. categorieZh = "家具家電";
  125. } else if (item.categories.includes("design-acceptanc-and-move-in")) {
  126. categorieZh = "驗收入住";
  127. }
  128. let dom = `
  129. <li>
  130. <a href="https://bhouse.com.tw/${item.url}">【${categorieZh}】 ${item.title}</a>
  131. </li>`;
  132. content.push(dom);
  133. }
  134. }
  135. document.querySelector('.read-more-list').innerHTML = content.join(" ");
  136. })
  137. let moreList = document.querySelector('.read-more-list');
  138. if (moreList.children.length === 1) {
  139. moreList.style.display = 'none';
  140. }
  141. })
  142. })();
  143. let contentList = document.getElementById("TableOfContents").getElementsByTagName("li");
  144. for (let i = 0; i < contentList.length; i++) {
  145. const element = contentList[i];
  146. if (element.childNodes.length == 0) {
  147. element.style.display = 'none';
  148. }
  149. }
  150. </script>
  151. {{ end }}