Compare commits
2
Commits
3c9b163dd4
...
0a16c5329d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a16c5329d | ||
|
|
aad8784b48 |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { useInfiniteQuery, useMutation, useQuery, useQueryClient, type InfiniteData } from '@tanstack/react-query'
|
||||
import { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from 'react'
|
||||
import regionPages from '../../seo/region.json'
|
||||
import { setTokens, subscribeAuth } from '../api/auth'
|
||||
import { SITE_URL } from '../api/setup'
|
||||
import {
|
||||
@@ -133,6 +134,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
{state.type === 'region' && <RegionSheet onDone={onClose} />}
|
||||
</div>
|
||||
)}
|
||||
{!state && <RegionLinks />}
|
||||
</dialog>
|
||||
)
|
||||
}
|
||||
@@ -987,6 +989,27 @@ function MeSheet({ onDone }: { onDone: () => void }) {
|
||||
/* ---------- 지역 ---------- */
|
||||
const LOCATE_TEXT = { idle: '', locating: '위치를 찾는 중이에요…', denied: '위치 권한이 꺼져 있어요. 아래 목록에서 골라 주세요.', error: '위치를 찾지 못했어요. 아래 목록에서 골라 주세요.' } as const
|
||||
|
||||
/** 구 코드 → 그 구가 속한 지역 페이지 주소 */
|
||||
const pageHref = (code: string) => {
|
||||
const p = regionPages.find((g) => g.regions.some((r) => r.code === code))
|
||||
return p ? `/today/${p.path}` : '/'
|
||||
}
|
||||
|
||||
/** 지역 바꾸기가 닫혀 있을 때도 지역 페이지 링크를 HTML에 둔다 (검색 로봇이 링크를 따라가게) */
|
||||
function RegionLinks() {
|
||||
return (
|
||||
<nav aria-label="지역별 오늘 날씨">
|
||||
<ul>
|
||||
{regionPages.map((p) => (
|
||||
<li key={p.path}>
|
||||
<a href={`/today/${p.path}`}>{p.name} 오늘 날씨</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
function RegionSheet({ onDone }: { onDone: () => void }) {
|
||||
const { region, setRegion, locate, locateStatus } = useRegion()
|
||||
const { me, logout } = useAuth()
|
||||
@@ -1018,10 +1041,11 @@ function RegionSheet({ onDone }: { onDone: () => void }) {
|
||||
<ul className={cx('mt-2 flex flex-col transition-opacity', list.isPlaceholderData && 'opacity-60')}>
|
||||
{regions.map((r) => (
|
||||
<li key={r.code}>
|
||||
<button
|
||||
type="button"
|
||||
<a
|
||||
href={pageHref(r.code)}
|
||||
aria-current={r.code === region.code ? 'true' : undefined}
|
||||
onClick={() => {
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
setRegion(r)
|
||||
track('region_change', { region_name: r.name, method: 'list' })
|
||||
onDone()
|
||||
@@ -1030,7 +1054,7 @@ function RegionSheet({ onDone }: { onDone: () => void }) {
|
||||
>
|
||||
{r.name}
|
||||
{r.code === region.code && <small className="font-sans text-xs font-extrabold">지금 보는 곳</small>}
|
||||
</button>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -63,12 +63,6 @@ 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, '&').replace(/"/g, '"')
|
||||
|
||||
function seoPages(): Plugin {
|
||||
@@ -98,7 +92,6 @@ 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`)
|
||||
|
||||
Reference in new issue
Block a user