-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: support basepath config for staticPath
- Loading branch information
1 parent
10bda5e
commit d8dddc0
Showing
27 changed files
with
8,822 additions
and
5,992 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* eslint-disable */ | ||
import { Query as Query0 } from '../pages' | ||
import { OptionalQuery as OptionalQuery1 } from '../pages/[pid]' | ||
import { Query as Query2 } from '../pages/blog/[...slug]' | ||
|
||
export const pagesPath = { | ||
_pid: (pid: string | number) => ({ | ||
$url: (url?: { query?: OptionalQuery1, hash?: string }) => ({ pathname: '/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash }) | ||
}), | ||
aaa: { | ||
_bbb: (bbb: string[]) => ({ | ||
ccc: { | ||
$url: (url?: { hash?: string }) => ({ pathname: '/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash }) | ||
} | ||
}), | ||
api: { | ||
samples: { | ||
$url: (url?: { hash?: string }) => ({ pathname: '/aaa/api/samples' as const, hash: url?.hash }) | ||
} | ||
} | ||
}, | ||
blog: { | ||
_slug: (slug: string[]) => ({ | ||
$url: (url: { query: Query2, hash?: string }) => ({ pathname: '/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash }) | ||
}), | ||
hoge: { | ||
_fuga: (fuga?: string[]) => ({ | ||
$url: (url?: { hash?: string }) => ({ pathname: '/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash }) | ||
}) | ||
} | ||
}, | ||
$url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) | ||
} | ||
|
||
export type PagesPath = typeof pagesPath | ||
|
||
export const staticPath = { | ||
aa_json: '/foo/bar/aa.json', | ||
bb: { | ||
cc_png: '/foo/bar/bb/cc.png' | ||
} | ||
} as const | ||
|
||
export type StaticPath = typeof staticPath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
basePath: '/foo/bar' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Link from 'next/link' | ||
|
||
export type OptionalQuery = { hoge: string } | ||
|
||
// `onClick`, `href`, and `ref` need to be passed to the DOM element | ||
// for proper handling | ||
const MyButton = React.forwardRef(({ onClick, href }, ref) => { | ||
return ( | ||
<a href={href} onClick={onClick} ref={ref}> | ||
Click Me | ||
</a> | ||
) | ||
}) | ||
|
||
function Home() { | ||
return ( | ||
<Link href="/about" passHref> | ||
<MyButton /> | ||
</Link> | ||
) | ||
} | ||
|
||
export default Home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { AppProps } from 'next/app' | ||
import '../styles/globals.css' | ||
|
||
function MyApp({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} /> | ||
} | ||
|
||
export default MyApp |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Link from 'next/link' | ||
|
||
export type Query = { hoge: string } | ||
|
||
// `onClick`, `href`, and `ref` need to be passed to the DOM element | ||
// for proper handling | ||
const MyButton = React.forwardRef(({ onClick, href }, ref) => { | ||
return ( | ||
<a href={href} onClick={onClick} ref={ref}> | ||
Click Me | ||
</a> | ||
) | ||
}) | ||
|
||
function Home() { | ||
return ( | ||
<Link href="/about" passHref> | ||
<MyButton /> | ||
</Link> | ||
) | ||
} | ||
|
||
export default Home |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import Head from 'next/head' | ||
import { useCallback, useState, FormEvent, ChangeEvent } from 'react' | ||
import useAspidaSWR from '@aspida/swr' | ||
import styles from '~/styles/Home.module.css' | ||
import { apiClient } from '~/utils/apiClient' | ||
import { Task } from '<%= orm === "prisma" ? "$prisma/client" : "$/types" %>' | ||
import UserBanner from '~/components/UserBanner' | ||
|
||
export type Query = { hoge: string } | ||
|
||
const Home = () => { | ||
const { data: tasks, error, revalidate } = useAspidaSWR(apiClient.tasks) | ||
const [label, setLabel] = useState('') | ||
const inputLabel = useCallback((e: ChangeEvent<HTMLInputElement>) => setLabel(e.target.value), []) | ||
|
||
const createTask = useCallback( | ||
async (e: FormEvent) => { | ||
e.preventDefault() | ||
if (!label) return | ||
|
||
await apiClient.tasks.post({ body: { label } }) | ||
setLabel('') | ||
revalidate() | ||
}, | ||
[label] | ||
) | ||
|
||
const toggleDone = useCallback(async (task: Task) => { | ||
await apiClient.tasks._taskId(task.id).patch({ body: { done: !task.done } }) | ||
revalidate() | ||
}, []) | ||
|
||
const deleteTask = useCallback(async (task: Task) => { | ||
await apiClient.tasks._taskId(task.id).delete() | ||
revalidate() | ||
}, []) | ||
|
||
if (error) return <div>failed to load</div> | ||
if (!tasks) return <div>loading...</div> | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<Head> | ||
<title>frourio-todo-app</title> | ||
<link rel="icon" href="/favicon.png" /> | ||
</Head> | ||
|
||
<main className={styles.main}> | ||
<UserBanner /> | ||
|
||
<h1 className={styles.title}> | ||
Welcome to <a href="https://nextjs.org">Next.js!</a> | ||
</h1> | ||
|
||
<p className={styles.description}>frourio-todo-app</p> | ||
|
||
<div> | ||
<form style={{ textAlign: 'center' }} onSubmit={createTask}> | ||
<input value={label} type="text" onChange={inputLabel} /> | ||
<input type="submit" value="ADD" /> | ||
</form> | ||
<ul className={styles.tasks}> | ||
{tasks.map(task => ( | ||
<li key={task.id}> | ||
<label> | ||
<input type="checkbox" checked={task.done} onChange={() => toggleDone(task)} /> | ||
<span>{task.label}</span> | ||
</label> | ||
<input | ||
type="button" | ||
value="DELETE" | ||
style={{ float: 'right' }} | ||
onClick={() => deleteTask(task)} | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</main> | ||
|
||
<footer className={styles.footer}> | ||
<a | ||
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Powered by <img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} /> | ||
</a> | ||
</footer> | ||
</div> | ||
) | ||
} | ||
|
||
export default Home |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
router: { | ||
trailingSlash: true, | ||
base: '/foo/bar' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Link from 'next/link' | ||
|
||
export type OptionalQuery = { hoge: string } | ||
|
||
// `onClick`, `href`, and `ref` need to be passed to the DOM element | ||
// for proper handling | ||
const MyButton = React.forwardRef(({ onClick, href }, ref) => { | ||
return ( | ||
<a href={href} onClick={onClick} ref={ref}> | ||
Click Me | ||
</a> | ||
) | ||
}) | ||
|
||
function Home() { | ||
return ( | ||
<Link href="/about" passHref> | ||
<MyButton /> | ||
</Link> | ||
) | ||
} | ||
|
||
export default Home |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Link from 'next/link' | ||
|
||
export type Query = { hoge: string } | ||
|
||
// `onClick`, `href`, and `ref` need to be passed to the DOM element | ||
// for proper handling | ||
const MyButton = React.forwardRef(({ onClick, href }, ref) => { | ||
return ( | ||
<a href={href} onClick={onClick} ref={ref}> | ||
Click Me | ||
</a> | ||
) | ||
}) | ||
|
||
function Home() { | ||
return ( | ||
<Link href="/about" passHref> | ||
<MyButton /> | ||
</Link> | ||
) | ||
} | ||
|
||
export default Home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import Head from 'next/head' | ||
import { useCallback, useState, FormEvent, ChangeEvent } from 'react' | ||
import useAspidaSWR from '@aspida/swr' | ||
import styles from '~/styles/Home.module.css' | ||
import { apiClient } from '~/utils/apiClient' | ||
import { Task } from '<%= orm === "prisma" ? "$prisma/client" : "$/types" %>' | ||
import UserBanner from '~/components/UserBanner' | ||
|
||
export type Query = { hoge: string } | ||
|
||
const Home = () => { | ||
const { data: tasks, error, revalidate } = useAspidaSWR(apiClient.tasks) | ||
const [label, setLabel] = useState('') | ||
const inputLabel = useCallback((e: ChangeEvent<HTMLInputElement>) => setLabel(e.target.value), []) | ||
|
||
const createTask = useCallback( | ||
async (e: FormEvent) => { | ||
e.preventDefault() | ||
if (!label) return | ||
|
||
await apiClient.tasks.post({ body: { label } }) | ||
setLabel('') | ||
revalidate() | ||
}, | ||
[label] | ||
) | ||
|
||
const toggleDone = useCallback(async (task: Task) => { | ||
await apiClient.tasks._taskId(task.id).patch({ body: { done: !task.done } }) | ||
revalidate() | ||
}, []) | ||
|
||
const deleteTask = useCallback(async (task: Task) => { | ||
await apiClient.tasks._taskId(task.id).delete() | ||
revalidate() | ||
}, []) | ||
|
||
if (error) return <div>failed to load</div> | ||
if (!tasks) return <div>loading...</div> | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<Head> | ||
<title>frourio-todo-app</title> | ||
<link rel="icon" href="/favicon.png" /> | ||
</Head> | ||
|
||
<main className={styles.main}> | ||
<UserBanner /> | ||
|
||
<h1 className={styles.title}> | ||
Welcome to <a href="https://nextjs.org">Next.js!</a> | ||
</h1> | ||
|
||
<p className={styles.description}>frourio-todo-app</p> | ||
|
||
<div> | ||
<form style={{ textAlign: 'center' }} onSubmit={createTask}> | ||
<input value={label} type="text" onChange={inputLabel} /> | ||
<input type="submit" value="ADD" /> | ||
</form> | ||
<ul className={styles.tasks}> | ||
{tasks.map(task => ( | ||
<li key={task.id}> | ||
<label> | ||
<input type="checkbox" checked={task.done} onChange={() => toggleDone(task)} /> | ||
<span>{task.label}</span> | ||
</label> | ||
<input | ||
type="button" | ||
value="DELETE" | ||
style={{ float: 'right' }} | ||
onClick={() => deleteTask(task)} | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</main> | ||
|
||
<footer className={styles.footer}> | ||
<a | ||
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Powered by <img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} /> | ||
</a> | ||
</footer> | ||
</div> | ||
) | ||
} | ||
|
||
export default Home |
Oops, something went wrong.