123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- {{ partial "headers.html" . }}
- </head>
- <body style="overflow-x: hidden;">
- {{ partial "nav.html" . }}
- <div class="container-fluid blog-categories p-0">
- <section class="bhouseweb_loc_banner">
- <img src="/img/banner/bn_blog@2x.png" class="banner-img card-img" alt="...">
- </section>
- <div class="container">
- <nav
- style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E");"
- aria-label="breadcrumb">
- <ol class="breadcrumb">
- <li class="breadcrumb-item"><a href="#"><img src="/img/bt_footer_index@2x.png" width="30px" alt=""
- style="margin-bottom: 5px;"></a></li>
- <li class="breadcrumb-item"><a href="#">成家知識專欄</a></li>
- <li class="breadcrumb-item active" aria-current="page">預售屋客變</li>
- </ol>
- </nav>
- <div class="d-flex flex-column align-items-start">
- <div class="link-list">
- <button><a href="">客廳</a></button>
- <button><a href="">主臥</a></button>
- <button><a href="">客房</a></button>
- <button><a href="">客廳</a></button>
- <button><a href="">主臥</a></button>
- <button><a href="">客房</a></button>
- </div>
- <div class="bhouseweb_loc_search_box">
- <form class="bhouseweb_search_form d-flex">
- <div class="bhouseweb_search_img" style="margin-right: 1vw;">
- <img src="/img/icon_search@2x.png" alt="">
- </div>
- <input id="blog_search" class="me-md-2" type="search" placeholder="搜尋「客變」「工業風」「三代同堂」" aria-label="Search">
- </form>
- </div>
- </div>
- </div>
- <div style="border-top: 1px solid #969696;"></div>
- <!-- <div class="alert d-flex align-items-center" role="alert" style="max-width: 300px;margin: auto;justify-content: center;">
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" style="color: #808e4c;" viewBox="0 0 16 16" role="img" aria-label="Warning:">
- <path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
- </svg>
- <div>
- 找不到符合條件的文章
- </div>
- </div> -->
- <div class="article" id="articleList">
- {{ $paginator := .Paginate .Data.Pages }}
- {{ range $paginator.Pages }}
- <div class="article-item">
- <a href="{{ .RelPermalink }}">
- <img src="{{ .Params.Image | relURL }}" alt="">
- </a>
- <div class="d-flex flex-column">
- <a href="{{ .RelPermalink }}">
- <h4>{{ .Title }}</h4>
- </a>
- <p class="mt-auto my-2 fw-bold">{{ .PublishDate.Format "2006-01-02" }}</p>
- <a href="{{ .RelPermalink }}" class="description">
- <p style="letter-spacing: 1px;">{{.Params.description }}</p>
- </a>
- <!-- <p style="color:#4D4D4D;">{{ .Summary }}</p> -->
- </div>
- </div>
- {{ end }}
- </div>
- <a class="nav-link article_readMore" href="/blog_main/">< 回到成家知識庫</a>
- </div>
- {{ partial "footer.html" . }}
- {{ partial "scripts.html" . }}
- <script>
- window.onload = function () {
- document.getElementById('blog_search').value = '';
- // 取得 apiData
- let contentsData = [];
- let category = localStorage.getItem('category');
- (function getContentsData() {
- // 線上版網址 http://192.53.174.202:9001/api/
- // 本地端網址 http://localhost:9001/api/
- fetch('http://localhost:9001/api/contents?url=/blog').then(res => res.json()).then(list => {
- contentsData = list;
- console.log('contentsData', contentsData);
- if (category !== null) {
- filterCategory();
- }
- })
- })();
- let matchContent = "";
- // 分類篩選
- function filterCategory() {
- contentsData.map(item => {
- if (item.categories) {
- if (item.categories.includes(category)) {
- matchContent += `
- <div class="article-item">
- <a href="${item.url}">
- <img src="${item.image}" alt="">
- </a>
- <div class="d-flex flex-column">
- <a href="${item.url}">
- <h4>${item.title}</h4>
- </a>
- <p class="mt-auto my-2 fw-bold">${item.date.substr(0, 10)}</p>
- <a href="${item.url}" class="description">
- <p style="letter-spacing: 1px;">${item.description}</p>
- </a>
- </div>
- </div>`
- }
- }
- })
- document.getElementById("articleList").innerHTML = matchContent;
- }
- // 增加延遲(待輸入完成後再進行搜尋)
- function delay(fn, ms) {
- let timer = 0
- return function (...args) {
- clearTimeout(timer)
- timer = setTimeout(fn.bind(this, ...args), ms || 0)
- }
- }
- // 搜尋
- $('#blog_search').keyup(delay(function (e) {
- // 取得輸入框的值
- let inputVal = $('#blog_search').val();
- matchContent = "";
- let falseItem = [];
- contentsData.map((item, index) => {
- // 搜尋特定分類文章
- // if (item.categories) {
- // if (item.categories.includes(category)) {
- // 搜尋所有分類文章
- if (item.title.includes(inputVal) || item.description.includes(inputVal) || item.content.includes(inputVal)) {
- matchContent += `
- <div class="article-item">
- <a href="${item.url}">
- <img src="${item.image}" alt="">
- </a>
- <div class="d-flex flex-column">
- <a href="${item.url}">
- <h4>${item.title}</h4>
- </a>
- <p class="mt-auto my-2 fw-bold">${item.date.substr(0, 10)}</p>
- <a href="${item.url}" class="description">
- <p style="letter-spacing: 1px;">${item.description}</p>
- </a>
- </div>
- </div>`
- } else {
- falseItem.push(item);
- }
- if (falseItem.length === contentsData.length) {
- matchContent = `
- <div class="alert d-flex align-items-center" role="alert" style="max-width: 300px;margin: 0 auto 25px;justify-content: center;">
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" style="color: #808e4c;" viewBox="0 0 16 16" role="img" aria-label="Warning:">
- <path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
- </svg>
- <div>
- 找不到符合條件的文章
- </div>
- </div>
- `;
- }
- // }
- // }
- })
- document.getElementById("articleList").innerHTML = matchContent;
- }, 500));
- }
- </script>
- </body>
- </html>
|