feat: 홈 첫 HTML에 시도별 지역 페이지 링크(230개)를 넣어 검색 로봇이 홈에서 지역 페이지로 이어지게

This commit is contained in:
minaChoi committed 2026-10-19 10:54:06 +09:00
1 parent b0cd5ef1ef
commit 3c9b163dd4
1 file changed
+7
+7
View File
@@ -63,6 +63,12 @@ for (const r of regionPages) {
})
}
/** 홈에만 넣는 시도별 지역 페이지 링크. 홈에서 지역 페이지로 바로 이어지게 한다 */
const sidos = [...new Set(regionPages.map((r) => r.name.split(' ')[0]))]
const regionLinks = `<h2>지역별 오늘 날씨</h2>${sidos
.map((s) => `<h3>${s}</h3><ul>${regionPages.filter((r) => r.name.split(' ')[0] === s).map((r) => `<li><a href="/today/${r.path}">${r.name}</a></li>`).join('')}</ul>`)
.join('')}`
const attr = (s: string) => s.replace(/&/g, '&amp;').replace(/"/g, '&quot;')
function seoPages(): Plugin {
@@ -92,6 +98,7 @@ function seoPages(): Plugin {
mkdirSync(dirname(file), { recursive: true })
writeFileSync(file, html)
}
writeFileSync(resolve(outDir, 'index.html'), base.replace('</main>', `${regionLinks}</main>`))
const today = new Date().toISOString().slice(0, 10)
const urls = ['', ...PAGES.map((p) => p.path)].map((path) => ` <url><loc>${site}/${path}</loc><lastmod>${today}</lastmod></url>`)
writeFileSync(resolve(outDir, 'sitemap.xml'), `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls.join('\n')}\n</urlset>\n`)