1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-30 22:08:02 +00:00
This commit is contained in:
Nebel 2020-06-11 20:59:34 +09:00
parent 026b6a9b63
commit 2e3ae535fc
7 changed files with 22 additions and 22 deletions

View file

@ -1,9 +1,9 @@
const NEXT_BASE_PATH = process.env.NEXT_ASSET_PREFIX || ""; const NEXT_BASE_PATH = process.env.NEXT_ASSET_PREFIX || "";
module.exports = require("@next/mdx")({ module.exports = require("@next/mdx")({
extension: /\.mdx?$/ extension: /\.mdx?$/,
})({ })({
pageExtensions: ["ts", "tsx", "md", "mdx"], pageExtensions: ["ts", "tsx", "md", "mdx"],
assetPrefix: NEXT_BASE_PATH, assetPrefix: NEXT_BASE_PATH,
env: { NEXT_BASE_PATH } env: { NEXT_BASE_PATH },
}); });

View file

@ -5,7 +5,7 @@ import Document, {
Html, Html,
Head, Head,
Main, Main,
NextScript NextScript,
} from "next/document"; } from "next/document";
import { ServerStyleSheets } from "@material-ui/styles"; import { ServerStyleSheets } from "@material-ui/styles";
import { theme } from "../styles/MainTheme"; import { theme } from "../styles/MainTheme";
@ -15,12 +15,12 @@ export default class extends Document {
const originalRenderPage = ctx.renderPage; const originalRenderPage = ctx.renderPage;
ctx.renderPage = () => ctx.renderPage = () =>
originalRenderPage({ originalRenderPage({
enhanceApp: App => props => sheets.collect(<App {...props} />) enhanceApp: (App) => (props) => sheets.collect(<App {...props} />),
}); });
const initialProps = await Document.getInitialProps(ctx); const initialProps = await Document.getInitialProps(ctx);
return { return {
...initialProps, ...initialProps,
styles: [initialProps.styles, sheets.getStyleElement()] styles: [initialProps.styles, sheets.getStyleElement()],
} as DocumentInitialProps; } as DocumentInitialProps;
}; };

View file

@ -8,7 +8,7 @@ export function getStaticProps({ params }: { params: unknown }) {
return { props: params }; return { props: params };
} }
export default function({ path }: { path: string }) { export default function ({ path }: { path: string }) {
const { query } = useRouter(); const { query } = useRouter();
return <pre>{JSON.stringify({ path, ...query }, null, " ")}</pre>; return <pre>{JSON.stringify({ path, ...query }, null, " ")}</pre>;
} }

View file

@ -17,7 +17,7 @@ type Action =
const initialState: State = { const initialState: State = {
id: 0, id: 0,
todo: new Map() todo: new Map(),
}; };
function reducer(state: State, action: Action) { function reducer(state: State, action: Action) {
@ -44,7 +44,7 @@ export default () => {
if (body.length === 0) return; if (body.length === 0) return;
dispatch({ dispatch({
type: "add", type: "add",
body body,
}); });
}, },
[dispatch] [dispatch]

View file

@ -3,6 +3,6 @@ import { Home, Info } from "@material-ui/icons";
const routes = [ const routes = [
{ pathname: "/", icon: createElement(Home) }, { pathname: "/", icon: createElement(Home) },
{ pathname: "/about", icon: createElement(Info) } { pathname: "/about", icon: createElement(Info) },
]; ];
export default routes; export default routes;

View file

@ -23,21 +23,21 @@ const isValidURL = (url: string) => {
export const theme = createMuiTheme({ export const theme = createMuiTheme({
palette: { palette: {
primary: { primary: {
main: orange[900] main: orange[900],
}, },
secondary: { secondary: {
main: teal[400] main: teal[400],
} },
}, },
typography: { typography: {
fontFamily: "sans-serif" fontFamily: "sans-serif",
} },
}); });
export const components: { export const components: {
[key in keyof HTMLElementTagNameMap]?: React.FC<any>; [key in keyof HTMLElementTagNameMap]?: React.FC<any>;
} = { } = {
h1: props => ( h1: (props) => (
<> <>
<Head> <Head>
<title>{props.children}</title> <title>{props.children}</title>
@ -45,11 +45,11 @@ export const components: {
<Typography component="h1" variant="h3" {...props} /> <Typography component="h1" variant="h3" {...props} />
</> </>
), ),
h2: props => <Typography component="h2" variant="h4" {...props} />, h2: (props) => <Typography component="h2" variant="h4" {...props} />,
h3: props => <Typography component="h3" variant="h5" {...props} />, h3: (props) => <Typography component="h3" variant="h5" {...props} />,
h4: props => <Typography component="h4" variant="h6" {...props} />, h4: (props) => <Typography component="h4" variant="h6" {...props} />,
h5: props => <Typography component="h5" variant="h6" {...props} />, h5: (props) => <Typography component="h5" variant="h6" {...props} />,
h6: props => <Typography variant="h6" {...props} />, h6: (props) => <Typography variant="h6" {...props} />,
a: ({ href, ...props }: { href: string }) => { a: ({ href, ...props }: { href: string }) => {
const url = `${process.env.NEXT_BASE_PATH}${href}`; const url = `${process.env.NEXT_BASE_PATH}${href}`;
return isValidURL(href) ? ( return isValidURL(href) ? (
@ -60,7 +60,7 @@ export const components: {
</Link> </Link>
); );
}, },
p: props => <Typography component="p" variant="body1" {...props} /> p: (props) => <Typography component="p" variant="body1" {...props} />,
}; };
const MainTheme: React.FC = ({ children }) => ( const MainTheme: React.FC = ({ children }) => (

View file

@ -10,7 +10,7 @@ const TopAppBar = () => {
const router = useRouter(); const router = useRouter();
const pathname = ( const pathname = (
routes.find(({ pathname }) => pathname === router.pathname) || { routes.find(({ pathname }) => pathname === router.pathname) || {
pathname: "/" pathname: "/",
} }
).pathname; ).pathname;
return ( return (