Skip to content

Commit daf8d1f

Browse files
committed
Merge branch 'develop'
2 parents 287017f + 4ed6a52 commit daf8d1f

2 files changed

Lines changed: 88 additions & 105 deletions

File tree

WebSite/tools/build-sitemap.js

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ const fs = require("fs");
22
const path = require("path");
33

44
const BASE_URL = "https://breadmotion.github.io";
5+
// プロジェクトのルート (breadmotion.github.io)
56
const ROOT = path.join(__dirname, "..", "..");
67
const OUTPUT = path.join(ROOT, "sitemap.xml");
78

9+
// サイトコンテンツのルート (breadmotion.github.io/WebSite)
10+
const WEBSITE_ROOT = path.join(ROOT, "WebSite");
11+
812
// スキャンから完全に除外するディレクトリ名
913
const IGNORE_DIRS = new Set([
1014
"node_modules",
@@ -52,7 +56,6 @@ function collectHtmlFiles(
5256
});
5357

5458
for (const entry of entries) {
55-
// 除外リストにあるディレクトリ名またはファイル名はスキップ
5659
if (
5760
IGNORE_DIRS.has(entry.name) ||
5861
IGNORE_FILES.has(entry.name)
@@ -78,33 +81,61 @@ function collectHtmlFiles(
7881
return allFiles;
7982
}
8083

81-
const htmlFiles = collectHtmlFiles(ROOT);
84+
// 収集の開始点を WebSite ディレクトリに変更
85+
const htmlFiles = collectHtmlFiles(WEBSITE_ROOT);
86+
87+
// プロジェクトルートにある index.html も手動で追加する
88+
if (fs.existsSync(path.join(ROOT, "index.html"))) {
89+
// WebSite/index.html と区別するために特別な名前を付けてリストに追加
90+
htmlFiles.push("ROOT_INDEX.html");
91+
}
8292

8393
function toUrl(relPath) {
94+
// プロジェクトルートの index.html を処理
95+
if (relPath === "ROOT_INDEX.html") {
96+
return `${BASE_URL}/`;
97+
}
98+
// WebSite ディレクトリ直下の index.html を処理
8499
if (relPath === "index.html") {
85100
return `${BASE_URL}/`;
86101
}
102+
// サブディレクトリ内の index.html を処理 (例: en/index.html -> /en/)
87103
if (relPath.endsWith("/index.html")) {
88104
return `${BASE_URL}/${relPath.substring(0, relPath.length - "index.html".length)}`;
89105
}
106+
// その他のHTMLファイル
90107
return `${BASE_URL}/${relPath.replace(/\\/g, "/")}`;
91108
}
92109

93110
function formatDate(d) {
94111
return d.toISOString().split("T")[0];
95112
}
96113

97-
const urlEntries = htmlFiles.map((relPath) => {
98-
const filePath = path.join(ROOT, relPath);
99-
const stat = fs.statSync(filePath);
100-
const lastmod = formatDate(stat.mtime);
101-
const loc = escapeXml(toUrl(relPath));
114+
const uniqueUrls = new Set();
115+
116+
const urlEntries = htmlFiles
117+
.map((relPath) => {
118+
const filePath =
119+
relPath === "ROOT_INDEX.html"
120+
? path.join(ROOT, "index.html")
121+
: path.join(WEBSITE_ROOT, relPath);
122+
123+
const stat = fs.statSync(filePath);
124+
const lastmod = formatDate(stat.mtime);
125+
const loc = escapeXml(toUrl(relPath));
126+
127+
// 重複するURLは追加しない (ルートURLなど)
128+
if (uniqueUrls.has(loc)) {
129+
return null;
130+
}
131+
uniqueUrls.add(loc);
102132

103-
return ` <url>
133+
return ` <url>
104134
<loc>${loc}</loc>
105135
<lastmod>${lastmod}</lastmod>
106136
</url>`;
107-
});
137+
})
138+
.filter((entry) => entry !== null); // null (重複エントリ) を除去
108139

109140
const xml = `<?xml version="1.0" encoding="UTF-8"?>
110141
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@@ -115,4 +146,4 @@ ${urlEntries.join("\n")}
115146
fs.writeFileSync(OUTPUT, xml.trim(), "utf8");
116147
console.log(`Sitemap generated: ${OUTPUT}`);
117148
console.log("Included URLs:");
118-
htmlFiles.forEach((rel) => console.log(" -", toUrl(rel)));
149+
uniqueUrls.forEach((url) => console.log(" -", url));

sitemap.xml

Lines changed: 47 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,231 +1,183 @@
1-
<?xml version="1.0" encoding="UTF-8" ?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
4-
<loc
5-
>https://breadmotion.github.io/</loc>zedLioeb orihect settu
4+
<loc>https://breadmotion.github.io/blog/blog_00001.html</loc>
65
<lastmod>2025-11-28</lastmod>
76
</url>
87
<url>
9-
<loc
10-
>https://breadmotion.github.io/WebSite/blog/blog_00001.html</loc>
8+
<loc>https://breadmotion.github.io/blog/blog_00002.html</loc>
119
<lastmod>2025-11-28</lastmod>
1210
</url>
1311
<url>
14-
<loc
15-
>https://breadmotion.github.io/WebSite/blog/blog_00002.html</loc>
12+
<loc>https://breadmotion.github.io/blog/blog_00003.html</loc>
1613
<lastmod>2025-11-28</lastmod>
1714
</url>
1815
<url>
19-
<loc
20-
>https://breadmotion.github.io/WebSite/blog/blog_00003.html</loc>
16+
<loc>https://breadmotion.github.io/blog/blog_00004.html</loc>
2117
<lastmod>2025-11-28</lastmod>
2218
</url>
2319
<url>
24-
<loc
25-
>https://breadmotion.github.io/WebSite/blog/blog_00004.html</loc>
20+
<loc>https://breadmotion.github.io/blog/blog_00005.html</loc>
2621
<lastmod>2025-11-28</lastmod>
2722
</url>
2823
<url>
29-
<loc
30-
>https://breadmotion.github.io/WebSite/blog/blog_00005.html</loc>
24+
<loc>https://breadmotion.github.io/blog/blog_00006.html</loc>
3125
<lastmod>2025-11-28</lastmod>
3226
</url>
3327
<url>
34-
<loc
35-
>https://breadmotion.github.io/WebSite/blog/blog_00006.html</loc>
28+
<loc>https://breadmotion.github.io/blog/blog_00007.html</loc>
3629
<lastmod>2025-11-28</lastmod>
3730
</url>
3831
<url>
39-
<loc
40-
>https://breadmotion.github.io/WebSite/blog/blog_00007.html</loc>
32+
<loc>https://breadmotion.github.io/blog/blog_00008.html</loc>
4133
<lastmod>2025-11-28</lastmod>
4234
</url>
4335
<url>
44-
<loc
45-
>https://breadmotion.github.io/WebSite/blog/blog_00008.html</loc>
36+
<loc>https://breadmotion.github.io/blog/blog_00009.html</loc>
4637
<lastmod>2025-11-28</lastmod>
4738
</url>
4839
<url>
49-
<loc
50-
>https://breadmotion.github.io/WebSite/blog/blog_00009.html</loc>
40+
<loc>https://breadmotion.github.io/blog/blog_00010.html</loc>
5141
<lastmod>2025-11-28</lastmod>
5242
</url>
5343
<url>
54-
<loc
55-
>https://breadmotion.github.io/WebSite/blog/blog_00010.html</loc>
44+
<loc>https://breadmotion.github.io/blog/blog_00011.html</loc>
5645
<lastmod>2025-11-28</lastmod>
5746
</url>
5847
<url>
59-
<loc
60-
>https://breadmotion.github.io/WebSite/blog/blog_00011.html</loc>
48+
<loc>https://breadmotion.github.io/blog/blog_00012.html</loc>
6149
<lastmod>2025-11-28</lastmod>
6250
</url>
6351
<url>
64-
<loc
65-
>https://breadmotion.github.io/WebSite/blog/blog_00012.html</loc>
52+
<loc>https://breadmotion.github.io/blog/blog_00013.html</loc>
6653
<lastmod>2025-11-28</lastmod>
6754
</url>
6855
<url>
69-
<loc
70-
>https://breadmotion.github.io/WebSite/blog/blog_00013.html</loc>
56+
<loc>https://breadmotion.github.io/blog/blog_00014.html</loc>
7157
<lastmod>2025-11-28</lastmod>
7258
</url>
7359
<url>
74-
<loc
75-
>https://breadmotion.github.io/WebSite/blog/blog_00014.html</loc>
60+
<loc>https://breadmotion.github.io/blog/blog_00015.html</loc>
7661
<lastmod>2025-11-28</lastmod>
7762
</url>
7863
<url>
79-
<loc
80-
>https://breadmotion.github.io/WebSite/blog/blog_00015.html</loc>
64+
<loc>https://breadmotion.github.io/blog/blog_00016.html</loc>
8165
<lastmod>2025-11-28</lastmod>
8266
</url>
8367
<url>
84-
<loc
85-
>https://breadmotion.github.io/WebSite/blog/blog_00016.html</loc>
68+
<loc>https://breadmotion.github.io/blog/en/blog_00001.html</loc>
8669
<lastmod>2025-11-28</lastmod>
8770
</url>
8871
<url>
89-
<loc
90-
>https://breadmotion.github.io/WebSite/blog/en/blog_00001.html</loc>
72+
<loc>https://breadmotion.github.io/blog/en/blog_00002.html</loc>
9173
<lastmod>2025-11-28</lastmod>
9274
</url>
9375
<url>
94-
<loc
95-
>https://breadmotion.github.io/WebSite/blog/en/blog_00002.html</loc>
76+
<loc>https://breadmotion.github.io/blog/en/blog_00003.html</loc>
9677
<lastmod>2025-11-28</lastmod>
9778
</url>
9879
<url>
99-
<loc
100-
>https://breadmotion.github.io/WebSite/blog/en/blog_00003.html</loc>
80+
<loc>https://breadmotion.github.io/blog/en/blog_00004.html</loc>
10181
<lastmod>2025-11-28</lastmod>
10282
</url>
10383
<url>
104-
<loc
105-
>https://breadmotion.github.io/WebSite/blog/en/blog_00004.html</loc>
84+
<loc>https://breadmotion.github.io/blog/en/blog_00005.html</loc>
10685
<lastmod>2025-11-28</lastmod>
10786
</url>
10887
<url>
109-
<loc
110-
>https://breadmotion.github.io/WebSite/blog/en/blog_00005.html</loc>
88+
<loc>https://breadmotion.github.io/blog/en/blog_00006.html</loc>
11189
<lastmod>2025-11-28</lastmod>
11290
</url>
11391
<url>
114-
<loc
115-
>https://breadmotion.github.io/WebSite/blog/en/blog_00006.html</loc>
92+
<loc>https://breadmotion.github.io/blog/en/blog_00007.html</loc>
11693
<lastmod>2025-11-28</lastmod>
11794
</url>
11895
<url>
119-
<loc
120-
>https://breadmotion.github.io/WebSite/blog/en/blog_00007.html</loc>
96+
<loc>https://breadmotion.github.io/blog/en/blog_00008.html</loc>
12197
<lastmod>2025-11-28</lastmod>
12298
</url>
12399
<url>
124-
<loc
125-
>https://breadmotion.github.io/WebSite/blog/en/blog_00008.html</loc>
100+
<loc>https://breadmotion.github.io/blog/en/blog_00009.html</loc>
126101
<lastmod>2025-11-28</lastmod>
127102
</url>
128103
<url>
129-
<loc
130-
>https://breadmotion.github.io/WebSite/blog/en/blog_00009.html</loc>
104+
<loc>https://breadmotion.github.io/blog/en/blog_00010.html</loc>
131105
<lastmod>2025-11-28</lastmod>
132106
</url>
133107
<url>
134-
<loc
135-
>https://breadmotion.github.io/WebSite/blog/en/blog_00010.html</loc>
108+
<loc>https://breadmotion.github.io/blog/en/blog_00011.html</loc>
136109
<lastmod>2025-11-28</lastmod>
137110
</url>
138111
<url>
139-
<loc
140-
>https://breadmotion.github.io/WebSite/blog/en/blog_00011.html</loc>
112+
<loc>https://breadmotion.github.io/blog/en/blog_00012.html</loc>
141113
<lastmod>2025-11-28</lastmod>
142114
</url>
143115
<url>
144-
<loc
145-
>https://breadmotion.github.io/WebSite/blog/en/blog_00012.html</loc>
116+
<loc>https://breadmotion.github.io/blog/en/blog_00013.html</loc>
146117
<lastmod>2025-11-28</lastmod>
147118
</url>
148119
<url>
149-
<loc
150-
>https://breadmotion.github.io/WebSite/blog/en/blog_00013.html</loc>
120+
<loc>https://breadmotion.github.io/blog/en/blog_00014.html</loc>
151121
<lastmod>2025-11-28</lastmod>
152122
</url>
153123
<url>
154-
<loc
155-
>https://breadmotion.github.io/WebSite/blog/en/blog_00014.html</loc>
124+
<loc>https://breadmotion.github.io/blog/en/blog_00015.html</loc>
156125
<lastmod>2025-11-28</lastmod>
157126
</url>
158127
<url>
159-
<loc
160-
>https://breadmotion.github.io/WebSite/blog/en/blog_00015.html</loc>
128+
<loc>https://breadmotion.github.io/blog/en/blog_00016.html</loc>
161129
<lastmod>2025-11-28</lastmod>
162130
</url>
163131
<url>
164-
<loc
165-
>https://breadmotion.github.io/WebSite/blog/en/blog_00016.html</loc>
132+
<loc>https://breadmotion.github.io/blog.html</loc>
166133
<lastmod>2025-11-28</lastmod>
167134
</url>
168135
<url>
169-
<loc
170-
>https://breadmotion.github.io/WebSite/blog.html</loc>
136+
<loc>https://breadmotion.github.io/contact.html</loc>
171137
<lastmod>2025-11-28</lastmod>
172138
</url>
173139
<url>
174-
<loc
175-
>https://breadmotion.github.io/WebSite/contact.html</loc>
140+
<loc>https://breadmotion.github.io/en/blog.html</loc>
176141
<lastmod>2025-11-28</lastmod>
177142
</url>
178143
<url>
179-
<loc
180-
>https://breadmotion.github.io/WebSite/en/blog.html</loc>
144+
<loc>https://breadmotion.github.io/en/contact.html</loc>
181145
<lastmod>2025-11-28</lastmod>
182146
</url>
183147
<url>
184-
<loc
185-
>https://breadmotion.github.io/WebSite/en/contact.html</loc>
148+
<loc>https://breadmotion.github.io/en/</loc>
186149
<lastmod>2025-11-28</lastmod>
187150
</url>
188151
<url>
189-
<loc>https://breadmotion.github.io/WebSite/en/</loc>
152+
<loc>https://breadmotion.github.io/en/portfolio.html</loc>
190153
<lastmod>2025-11-28</lastmod>
191154
</url>
192155
<url>
193-
<loc
194-
>https://breadmotion.github.io/WebSite/en/portfolio.html</loc>
156+
<loc>https://breadmotion.github.io/en/products.html</loc>
195157
<lastmod>2025-11-28</lastmod>
196158
</url>
197159
<url>
198-
<loc
199-
>https://breadmotion.github.io/WebSite/en/products.html</loc>
160+
<loc>https://breadmotion.github.io/</loc>
200161
<lastmod>2025-11-28</lastmod>
201162
</url>
202163
<url>
203-
<loc>https://breadmotion.github.io/WebSite/</loc>
164+
<loc>https://breadmotion.github.io/portfolio/portfolio_0001.html</loc>
204165
<lastmod>2025-11-28</lastmod>
205166
</url>
206167
<url>
207-
<loc
208-
>https://breadmotion.github.io/WebSite/portfolio/portfolio_0001.html</loc>
168+
<loc>https://breadmotion.github.io/portfolio/portfolio_0002.html</loc>
209169
<lastmod>2025-11-28</lastmod>
210170
</url>
211171
<url>
212-
<loc
213-
>https://breadmotion.github.io/WebSite/portfolio/portfolio_0002.html</loc>
172+
<loc>https://breadmotion.github.io/portfolio/portfolio_0003.html</loc>
214173
<lastmod>2025-11-28</lastmod>
215174
</url>
216175
<url>
217-
<loc
218-
>https://breadmotion.github.io/WebSite/portfolio/portfolio_0003.html</loc>
176+
<loc>https://breadmotion.github.io/portfolio.html</loc>
219177
<lastmod>2025-11-28</lastmod>
220178
</url>
221179
<url>
222-
<loc
223-
>https://breadmotion.github.io/WebSite/portfolio.html</loc>
180+
<loc>https://breadmotion.github.io/products.html</loc>
224181
<lastmod>2025-11-28</lastmod>
225182
</url>
226-
<url>
227-
<loc
228-
>https://breadmotion.github.io/WebSite/products.html</loc>
229-
<lastmod>2025-11-28</lastmod>
230-
</url>
231-
</urlset>
183+
</urlset>

0 commit comments

Comments
 (0)