dh_demo

DreamHanks demo project
git clone git://git.lair.cx/dh_demo
Log | Files | Refs | README

commit a1308acc617b42b059b03eaf9c80e0eb681d1bcc
parent 01f5636937d484185a4044cc9a059aad2e991d40
Author: Yongbin Kim <iam@yongbin.kim>
Date:   Mon, 30 Jan 2023 05:02:29 +0900

feat: 초기 페이지 리다이렉트 추가

Signed-off-by: Yongbin Kim <iam@yongbin.kim>

Diffstat:
A.swc/plugins/v4/7cbcd40fd93ab85d555d0d3d32b2b438cc33b85b1b80b06c2ff1f1b0b45e998e | 0
Mlib/utils/wiki.ts | 11++++-------
Mnext.config.js | 9---------
Apages/index.tsx | 27+++++++++++++++++++++++++++
4 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/.swc/plugins/v4/7cbcd40fd93ab85d555d0d3d32b2b438cc33b85b1b80b06c2ff1f1b0b45e998e b/.swc/plugins/v4/7cbcd40fd93ab85d555d0d3d32b2b438cc33b85b1b80b06c2ff1f1b0b45e998e Binary files differ. diff --git a/lib/utils/wiki.ts b/lib/utils/wiki.ts @@ -7,13 +7,10 @@ export const getSlugAndPath = ( context: GetServerSidePropsContext | NextApiRequest | NextRouter, ): [slug: string | null, path: string | null] => { const { slug, path } = context.query - if (typeof slug !== 'string') { - return [null, null] - } - if (path == null || !Array.isArray(path)) { - return [slug, null] - } - return [slug, path.join('')] + return [ + typeof slug === 'string' ? slug : null, + path != null && Array.isArray(path) ? path.join('') : null + ] } export const getStringFromWikiText = async (wikiText: WikiText): Promise<string> => { diff --git a/next.config.js b/next.config.js @@ -1,15 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, - async redirects () { - return [ - { - source: '/', - destination: '/home', - permanent: true, - }, - ] - }, experimental: { swcPlugins: [ [ diff --git a/pages/index.tsx b/pages/index.tsx @@ -0,0 +1,27 @@ +import { GetServerSideProps } from 'next' +import Link from 'next/link' + +export interface IndexPageProps { + homePath: string +} + +export const getServerSideProps: GetServerSideProps<IndexPageProps> = async (context) => { + const homePath = `/wiki/${process.env.WIKI_HOME_WIKI}/${process.env.WIKI_PAGE_ENTRY}` + return { + redirect: { + destination: homePath, + }, + props: { + homePath + } + } +} + +export default function IndexPage (props: IndexPageProps) { + return ( + <div> + 페이지가 나타나지 않는 경우, + <Link href={props.homePath}>여기</Link>를 눌러 이동하세요. + </div> + ) +}