fix: 지역 날씨 페이지 소개 글(제목·요약·자주 묻는 질문)을 앱이 뜬 뒤에도 피드 아래에 남김 — 구글은 JS 실행 뒤 화면으로 색인하는데 앱이 #root 를 덮어 '성남 오늘 날씨' 글이 사라졌음
This commit is contained in:
1 parent
f7a2a98e94
commit
9fdd299251
3 files changed
+26
-8
No files matched your search
@@ -30,7 +30,7 @@ import { usePinnedLike } from './pinnedLike'
|
||||
import { ShortsRail } from './Shorts'
|
||||
import { FeedComposer, NearTalks, TalkGroup } from './talk'
|
||||
import { topicName, useTalkGroups, useTodayMyTalks } from './talkState'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useLandingAbout, useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { useSky } from './skyContext'
|
||||
import { DayShareCard, DayShareGrid, GakShareCard, type DayShare } from './shareCards'
|
||||
@@ -577,6 +577,7 @@ function SeasonBand({ news }: { news: BandArticle[] }) {
|
||||
|
||||
export function TodayPage() {
|
||||
const { region } = useRegion()
|
||||
const about = useLandingAbout()
|
||||
const feed = useQuery(getFeedOptions({ query: { region: region.code } }))
|
||||
const today = useQuery(getWeatherTodayOptions({ query: { region: region.code } }))
|
||||
const { preview } = useSky()
|
||||
@@ -682,6 +683,13 @@ export function TodayPage() {
|
||||
{feed.isSuccess && spreadLeft}
|
||||
{feed.isSuccess && bandAt.filter(([at]) => at > posts.length).map(([at, node]) => <Fragment key={at}>{node}</Fragment>)}
|
||||
</div>
|
||||
{about && (
|
||||
<div
|
||||
data-nosnippet
|
||||
className="mx-4 mt-6 mb-4 text-[13px] leading-relaxed text-(--ink3) [&_a]:underline [&_h1]:mb-1 [&_h1]:text-[15px] [&_h1]:font-bold [&_h1]:text-(--ink2) [&_h2]:mt-4 [&_h2]:mb-1 [&_h2]:text-[14px] [&_h2]:font-bold [&_h2]:text-(--ink2) [&_h3]:mt-2 [&_h3]:font-semibold [&_li]:inline [&_li]:mr-2 [&_p]:my-1 [&_ul]:m-0 [&_ul]:p-0"
|
||||
dangerouslySetInnerHTML={{ __html: about }}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -5,18 +5,12 @@ import { nearestRegion } from '@nalssigak/shared/api/client/sdk.gen'
|
||||
import type { RegionData } from '@nalssigak/shared/api/client/types.gen'
|
||||
import { track } from '../lib/analytics'
|
||||
import { IS_TOSS, tossLocation } from '../lib/platform'
|
||||
import { DEFAULT_REGION, ownPage, RegionContext, type LocateStatus } from './regionContext'
|
||||
import { DEFAULT_REGION, ownPage, pageOf, RegionContext, type LocateStatus } from './regionContext'
|
||||
|
||||
const KEY = 'nalssigak.b.region'
|
||||
|
||||
type RegionPage = (typeof regionPages)[number]
|
||||
|
||||
/** /today/gyeonggi/seongnam, /tomorrow/gyeonggi/seongnam/bundang 같은 지역 페이지 주소면 그 페이지 */
|
||||
function pageOf(pathname: string): RegionPage | undefined {
|
||||
const path = pathname.match(/^\/(?:today|tomorrow)\/([a-z]+\/[a-z]+(?:\/[a-z]+)?)\/?$/)?.[1]
|
||||
return path ? regionPages.find((p) => p.path === path) : undefined
|
||||
}
|
||||
|
||||
/** 지역 페이지 안의 구: 구로 나뉜 시는 r 이 그 시 안이면 r, 아니면 시청이 있는 구 */
|
||||
function regionIn(page: RegionPage, r?: RegionData | null): RegionData {
|
||||
return page.regions.find((g) => g.code === r?.code) ?? page.regions.find((g) => g.code === page.main)!
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createContext, use } from 'react'
|
||||
import { useLocation } from 'react-router'
|
||||
import type { RegionData } from '@nalssigak/shared/api/client/types.gen'
|
||||
import regionPages from '../../seo/region.json'
|
||||
|
||||
@@ -11,6 +12,21 @@ export { DEFAULT_REGION } from '@nalssigak/shared/lib'
|
||||
/** 구 하나만 보여 주는 지역 페이지: 일반 시군구, 또는 구로 나뉜 시의 구 페이지 */
|
||||
export const ownPage = (code: string) => regionPages.find((p) => p.regions.length === 1 && p.regions[0].code === code)
|
||||
|
||||
/** /today/gyeonggi/seongnam, /tomorrow/gyeonggi/seongnam/bundang 같은 지역 페이지 주소면 그 페이지 */
|
||||
export function pageOf(pathname: string) {
|
||||
const path = pathname.match(/^\/(?:today|tomorrow)\/([a-z]+\/[a-z]+(?:\/[a-z]+)?)\/?$/)?.[1]
|
||||
return path ? regionPages.find((p) => p.path === path) : undefined
|
||||
}
|
||||
|
||||
/** 지역 페이지로 들어오면 서버가 채운 소개 글(#root 안)을 앱이 덮기 전에 잡아 둔다. 구글은 JS 실행 뒤 화면으로 색인한다 */
|
||||
const landingAbout = pageOf(location.pathname) ? { path: location.pathname, html: document.querySelector('#root > main')?.innerHTML ?? '' } : null
|
||||
|
||||
/** 들어온 지역 페이지에 그대로 있을 때만 그 소개 글 */
|
||||
export function useLandingAbout(): string | null {
|
||||
const { pathname } = useLocation()
|
||||
return landingAbout?.html && landingAbout.path === pathname ? landingAbout.html : null
|
||||
}
|
||||
|
||||
export const RegionContext = createContext<RegionApi | null>(null)
|
||||
|
||||
export function useRegion() {
|
||||
|
||||
Reference in new issue
Block a user