Skip to content

Commit

Permalink
Merge pull request #26 from calliope-pro/feature/incorporate-serversi…
Browse files Browse the repository at this point in the history
…deprops

Feature/incorporate isr
  • Loading branch information
calliope-pro authored Sep 28, 2022
2 parents 7982b36 + e7c1ca8 commit 3591f70
Show file tree
Hide file tree
Showing 50 changed files with 2,085 additions and 2,175 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"no-var": "error",
"prefer-const": "error",
"no-console": "warn",
"no-restricted-imports": ["error", {"patterns": ["../"]}],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-misused-promises": [
"error",
Expand Down
13 changes: 7 additions & 6 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": false
}
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": false,
"tabWidth": 4
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"dayjs": "^1.10.7",
"lodash": "^4.17.21",
"markdown-to-txt": "^2.0.0",
"next": "^12.0.8",
"next": "^12.3.1",
"next-absolute-url": "^1.2.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.22.2",
"react-icons": "^4.3.1",
"react-intersection-observer": "^8.33.1",
Expand Down
4 changes: 2 additions & 2 deletions src/atoms/authAtom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { atom } from 'recoil';

export const isAuthenticatedState = atom<boolean>({
key: 'isAuthenticatedState',
default: false,
key: 'isAuthenticatedState',
default: false,
});
4 changes: 2 additions & 2 deletions src/atoms/codeStyleAtom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { atom } from 'recoil';

export const isDarkState = atom<boolean>({
key: 'isDarkState',
default: true,
key: 'isDarkState',
default: true,
});
135 changes: 72 additions & 63 deletions src/components/BlogDetail/BlogIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,84 @@ import Link from 'next/link';
import { useState } from 'react';
import ReactMarkdown from 'react-markdown';
import {
Box,
Collapse,
IconButton,
Link as MuiLink,
List,
ListItem,
Stack,
Typography,
Box,
Collapse,
IconButton,
Link as MuiLink,
List,
ListItem,
Stack,
Typography,
} from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';
import ListIcon from '@mui/icons-material/List';

import { COLORS } from '#src/styles';

export const BlogIndex: React.FC<{ body: string }> = ({ body }) => {
const [isHidden, setIsHidden] = useState(true);
return (
<Box>
<Stack direction="row" justifyContent="space-between" alignItems="center">
<Typography fontSize="24px" color={COLORS.baseColor}>
目次
</Typography>
{isHidden ? (
<IconButton onClick={() => setIsHidden(false)}>
<ListIcon
sx={{
fontSize: '40px',
color: COLORS.accentDarkColor,
cursor: 'pointer',
}}
/>
</IconButton>
) : (
<IconButton onClick={() => setIsHidden(true)}>
<CloseIcon
sx={{
fontSize: '40px',
color: COLORS.accentDarkColor,
cursor: 'pointer',
}}
/>
</IconButton>
)}
</Stack>
<Collapse in={!isHidden}>
<List>
<ReactMarkdown
allowedElements={['h1']}
includeElementIndex
components={{
h1: ({ children, node, index }) => (
<ListItem dense>
<Link href={`#${node.position!.start.line}`} passHref>
<MuiLink
underline="none"
color={COLORS.baseColor}
fontSize="18px"
const [isHidden, setIsHidden] = useState(true);
return (
<Box>
<Stack
direction="row"
justifyContent="space-between"
alignItems="center"
>
<Typography fontSize="24px" color={COLORS.baseColor}>
目次
</Typography>
{isHidden ? (
<IconButton onClick={() => setIsHidden(false)}>
<ListIcon
sx={{
fontSize: '40px',
color: COLORS.accentDarkColor,
cursor: 'pointer',
}}
/>
</IconButton>
) : (
<IconButton onClick={() => setIsHidden(true)}>
<CloseIcon
sx={{
fontSize: '40px',
color: COLORS.accentDarkColor,
cursor: 'pointer',
}}
/>
</IconButton>
)}
</Stack>
<Collapse in={!isHidden}>
<List>
<ReactMarkdown
allowedElements={['h1']}
includeElementIndex
components={{
h1: ({ children, node, index }) => (
<ListItem dense>
<Link
href={`#${node.position!.start.line}`}
passHref
>
<MuiLink
underline="none"
color={COLORS.baseColor}
fontSize="18px"
>
{`${
index! + 1
}. ${children.toString()}`}
</MuiLink>
</Link>
</ListItem>
),
}}
>
{`${index! + 1}. ${children.toString()}`}
</MuiLink>
</Link>
</ListItem>
),
}}
>
{body}
</ReactMarkdown>
</List>
</Collapse>
</Box>
);
{body}
</ReactMarkdown>
</List>
</Collapse>
</Box>
);
};
28 changes: 0 additions & 28 deletions src/components/BlogDetail/BlogNotFound.tsx

This file was deleted.

91 changes: 36 additions & 55 deletions src/components/BlogDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,43 @@ import dayjs from 'dayjs';
import Head from 'next/head';
import { Box, Container, Divider, Typography } from '@mui/material';

import { Loader, MarkdownView, ShareButtons } from '#src/components';
import { useBlogListState } from '#src/utils/hooks';
import { MarkdownView, ShareButtons } from '#src/components';
import { BlogIndex } from './BlogIndex';
import { BlogNotFound } from './BlogNotFound';

export const BlogDetail: React.FC<{ uuid: string }> = ({ uuid }) => {
const { data } = useBlogListState();
if (!data) {
return <Loader />;
}
const blogData = data.find((blog) => blog.uuid === uuid);
if (!blogData) {
import { Blog } from '#src/types';

export const BlogDetail: React.FC<{ blog: Blog }> = ({ blog }) => {
return (
<>
<Head>
<title>ブログが存在しません</title>
</Head>

<Container>
<BlogNotFound />
</Container>
</>
<>
<Head>
<title>{blog.title}</title>
<meta name="description" content={blog.description} />
</Head>

<Container>
<ShareButtons />

<Box paddingTop={3} textAlign="center">
<Typography variant="h2">{blog.title}</Typography>
<Typography variant="h5">{blog.sub_title}</Typography>
</Box>

<Box textAlign="right">
<Typography variant="caption" display="block">
作成日時:&nbsp;
{dayjs.unix(blog.created_at).format('YYYY年MM月DD日')}
</Typography>
<Typography variant="caption" display="block">
更新日時:&nbsp;
{dayjs.unix(blog.updated_at).format('YYYY年MM月DD日')}
</Typography>
</Box>

<BlogIndex body={blog.content} />

<Divider sx={{ borderWidth: 'thin' }} />

<MarkdownView body={blog.content} />
</Container>
</>
);
}
return (
<>
<Head>
<title>{blogData.title}</title>
<meta name="description" content={blogData.description} />
</Head>

<Container>
<ShareButtons />

<Box paddingTop={3} textAlign="center">
<Typography variant="h2">{blogData.title}</Typography>
<Typography variant="h5">{blogData.sub_title}</Typography>
</Box>

<Box textAlign="right">
<Typography variant="caption" display="block">
作成日時:&nbsp;
{dayjs.unix(blogData.created_at).format('YYYY年MM月DD日')}
</Typography>
<Typography variant="caption" display="block">
更新日時:&nbsp;
{dayjs.unix(blogData.updated_at).format('YYYY年MM月DD日')}
</Typography>
</Box>

<BlogIndex body={blogData.content} />

<Divider sx={{ borderWidth: 'thin' }} />

<MarkdownView body={blogData.content} />
</Container>
</>
);
};
Loading

1 comment on commit 3591f70

@vercel
Copy link

@vercel vercel bot commented on 3591f70 Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.