Skip to content

Commit df2c333

Browse files
author
y-yamasaki
committed
タグフィルター調整
1 parent d3d490d commit df2c333

5 files changed

Lines changed: 38 additions & 23 deletions

File tree

WebSite/assets/css/layout.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,6 @@ body.no-scroll .site-header {
512512
margin-bottom: 1rem;
513513
flex-grow: 1;
514514
display: -webkit-box;
515-
-webkit-line-clamp: 3;
516-
-webkit-box-orient: vertical;
517515
overflow: hidden;
518516
}
519517

WebSite/assets/js/blog.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ document.addEventListener("DOMContentLoaded", () => {
6060
const res = await fetch("assets/data/blogList.json");
6161
if (!res.ok) throw new Error(`HTTP ${res.status}`);
6262
allPosts = await res.json();
63+
updateCategoryFilter();
6364
readInitialParams();
6465
render();
6566
} catch (err) {
@@ -72,6 +73,35 @@ document.addEventListener("DOMContentLoaded", () => {
7273
}
7374
}
7475

76+
// -----------------------------
77+
// カテゴリフィルタ更新
78+
// -----------------------------
79+
function updateCategoryFilter() {
80+
if (!categorySelect) return;
81+
82+
const categories = [
83+
...new Set(
84+
allPosts.map((p) => p.category).filter(Boolean),
85+
),
86+
].sort();
87+
88+
// 既存のオプション("すべて"以外)をクリア
89+
const currentValue = categorySelect.value;
90+
while (categorySelect.options.length > 1) {
91+
categorySelect.remove(1);
92+
}
93+
94+
categories.forEach((cat) => {
95+
const option = document.createElement("option");
96+
option.value = cat;
97+
option.textContent = cat;
98+
categorySelect.appendChild(option);
99+
});
100+
101+
// 以前選択されていた値を復元
102+
categorySelect.value = currentValue;
103+
}
104+
75105
// -----------------------------
76106
// 描画
77107
// -----------------------------

WebSite/blog.html

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,6 @@ <h2>記事一覧</h2>
135135
<option value="">
136136
すべて
137137
</option>
138-
<option value="Unity">
139-
Unity
140-
</option>
141-
<option value="UE5">
142-
UE5
143-
</option>
144-
<option
145-
value="プラグイン"
146-
>
147-
プラグイン
148-
</option>
149-
<option value="日記">
150-
日記
151-
</option>
152138
</select>
153139
</div>
154140

WebSite/sitemap.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
</url>
6767
<url>
6868
<loc>https://breadmotion.github.io/WebSite/blog.html</loc>
69-
<lastmod>2025-11-27</lastmod>
69+
<lastmod>2025-11-28</lastmod>
7070
</url>
7171
<url>
7272
<loc>https://breadmotion.github.io/WebSite/contact.html</loc>

WebSite/tools/build-blog.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,13 @@ ${bodyHtml}
281281

282282
const recommended = data.recommended || false;
283283
const tagsRaw = data.tags || [];
284-
const tags = Array.isArray(tagsRaw)
285-
? tagsRaw
286-
: String(tagsRaw)
287-
.split(",")
288-
.map((t) => t.trim())
289-
.filter(Boolean);
284+
const tags = (
285+
Array.isArray(tagsRaw)
286+
? tagsRaw
287+
: String(tagsRaw).split(",")
288+
)
289+
.map((t) => String(t).trim())
290+
.filter(Boolean);
290291

291292
const relPath = `blog/${id}.html`;
292293

0 commit comments

Comments
 (0)