-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Cattttttttt/dev
FIrst production version
- Loading branch information
Showing
80 changed files
with
5,116 additions
and
312 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
# Blog | ||
|
||
TODO | ||
### TODOS | ||
- [x] fix display bugs when down md and open menu | ||
- [x] add header picture text | ||
- [x] add fab | ||
- [x] add layout for main page | ||
- [x] impl scroll to load more | ||
- [x] impl article page using remark & rehype, using ketax | ||
- [x] impl archives page | ||
- [x] impl tags page | ||
- [ ] impl about page (using mdx?) | ||
- [x] impl friend link page | ||
- [ ] add dark mode | ||
- [x] change header picture, bing api? | ||
- [ ] add search | ||
- [ ] add comment system, maybe gittalk? | ||
- [ ] impl pwa for mobile | ||
- [ ] maybe add more animations to main page load more? | ||
- [ ] impl sidebar TOC for article page | ||
- [x] error page | ||
- [ ] add i18n | ||
- [ ] add semantic html | ||
- [ ] add accessibility | ||
- [ ] refactor code, using mui typography for different font style | ||
- [ ] seperate category from tag | ||
- [ ] add rss |
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,2 @@ | ||
export * from './tagContainer'; | ||
export * from './linkContainer'; |
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,71 @@ | ||
import { | ||
type FC, | ||
useState, | ||
useEffect, | ||
useCallback, | ||
type ReactNode, | ||
} from 'react'; | ||
import { Box, Theme, Slide, Fab } from '@mui/material'; | ||
import { ExpandLess } from '@mui/icons-material'; | ||
import { throttle } from 'throttle-debounce'; | ||
|
||
import { AppHeader } from './header'; | ||
|
||
export interface AppLayoutProps { | ||
fabActiveHeight?: number; | ||
children: ReactNode; | ||
} | ||
|
||
export const AppLayout: FC<AppLayoutProps> = (props) => { | ||
const [fabShow, setFabShow] = useState(false); | ||
|
||
useEffect(() => { | ||
const onScroll = throttle(50, () => { | ||
setFabShow( | ||
() => | ||
!!props.fabActiveHeight && | ||
document.documentElement.scrollTop > | ||
(props.fabActiveHeight / 100) * window.innerHeight | ||
); | ||
}); | ||
onScroll(); | ||
document.addEventListener('scroll', onScroll); | ||
return () => document.removeEventListener('scroll', onScroll); | ||
}, [props.fabActiveHeight]); | ||
|
||
const handleFabClick = useCallback(() => { | ||
window.scrollTo({ | ||
top: 0, | ||
behavior: 'smooth', | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<AppHeader /> | ||
<Box | ||
sx={{ | ||
backgroundColor: (theme: Theme) => theme.palette.grey[200], | ||
minHeight: '100vh', | ||
}} | ||
> | ||
{props.children} | ||
</Box> | ||
<Slide direction="up" in={fabShow}> | ||
<Fab | ||
size="medium" | ||
onClick={handleFabClick} | ||
sx={{ | ||
position: 'fixed', | ||
bottom: 24, | ||
right: 24, | ||
borderRadius: '4px', | ||
backgroundColor: 'common.white', | ||
}} | ||
> | ||
<ExpandLess fontSize="large" /> | ||
</Fab> | ||
</Slide> | ||
</> | ||
); | ||
}; |
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,71 @@ | ||
import { Container, Theme, Paper } from '@mui/material'; | ||
import { type FC, useState, useEffect } from 'react'; | ||
import { throttle } from 'throttle-debounce'; | ||
|
||
import type { DefaultLayoutProps } from './defaultLayout'; | ||
|
||
export const BodyContainer: FC<DefaultLayoutProps> = ({ | ||
headerHeight, | ||
children, | ||
}) => { | ||
const [paperMarginTop, setPaperMarginTop] = useState(2); | ||
|
||
useEffect(() => { | ||
const calculateMarginTop = () => | ||
Math.min( | ||
6, | ||
((document.documentElement.clientHeight - | ||
(headerHeight / 100) * window.innerHeight + | ||
document.documentElement.scrollTop) / | ||
(0.8 * window.innerHeight)) * | ||
6 | ||
); | ||
const onScroll = throttle(10, (ev?: Event) => { | ||
if (!ev) setPaperMarginTop(calculateMarginTop()); | ||
else | ||
setPaperMarginTop((cur) => { | ||
return document.documentElement.scrollTop + | ||
document.documentElement.clientHeight + | ||
0.1 * window.innerHeight > | ||
document.documentElement.scrollHeight | ||
? cur | ||
: calculateMarginTop(); | ||
}); | ||
}); | ||
onScroll(); | ||
document.addEventListener('scroll', onScroll); | ||
return () => document.removeEventListener('scroll', onScroll); | ||
}, [headerHeight]); | ||
|
||
return ( | ||
<Container | ||
sx={{ | ||
maxWidth: (theme: Theme) => ({ | ||
sm: theme.contentWidthScale * theme.breakpoints.values.sm, | ||
md: theme.contentWidthScale * theme.breakpoints.values.md, | ||
lg: theme.contentWidthScale * theme.breakpoints.values.lg, | ||
}), | ||
padding: { | ||
xs: '0 0 2rem 0', | ||
sm: 'initial initial 2rem initial', | ||
}, | ||
}} | ||
> | ||
<Paper | ||
elevation={18} | ||
sx={{ | ||
padding: '2rem', | ||
marginTop: { | ||
xs: '0', | ||
sm: `-${paperMarginTop}rem`, | ||
}, | ||
minHeight: `${100 - headerHeight}vh`, | ||
borderRadius: '0.5rem', | ||
display: 'flex', | ||
}} | ||
> | ||
{children} | ||
</Paper> | ||
</Container> | ||
); | ||
}; |
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,36 @@ | ||
import { Box } from '@mui/material'; | ||
import type { FC } from 'react'; | ||
|
||
import type { DefaultLayoutProps } from './defaultLayout'; | ||
import { HeaderTitle } from './headerTitle'; | ||
|
||
export const BodyHeader: FC<Omit<DefaultLayoutProps, 'children'>> = (props) => ( | ||
<Box | ||
sx={{ | ||
height: `${props.headerHeight}vh`, | ||
background: `rgba(0, 0, 0, 0) url("${ | ||
props.headerBanner || | ||
process.env.NEXT_PUBLIC_HEADER_PICTURE_FALLBACK || | ||
'http://api.dujin.org/bing/1920.php' | ||
}") no-repeat scroll center center / cover`, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
height: '100%', | ||
backgroundColor: 'rgba(0, 0, 0, 0.3)', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
px: '10%', | ||
}} | ||
> | ||
{props.headerTitle && | ||
(typeof props.headerTitle === 'string' ? ( | ||
<HeaderTitle>{props.headerTitle}</HeaderTitle> | ||
) : ( | ||
props.headerTitle | ||
))} | ||
</Box> | ||
</Box> | ||
); |
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,19 @@ | ||
import type { FC, ReactElement, ReactNode } from 'react'; | ||
import { BodyContainer } from './bodyContainer'; | ||
import { BodyHeader } from './bodyHeader'; | ||
|
||
export interface DefaultLayoutProps { | ||
headerTitle?: string | ReactElement; | ||
headerHeight: number; | ||
headerBanner?: string; | ||
children: ReactNode; | ||
} | ||
|
||
export const DefaultLayout: FC<DefaultLayoutProps> = (props) => { | ||
return ( | ||
<> | ||
<BodyHeader {...props} /> | ||
<BodyContainer {...props} /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.
b8bee56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blog – ./
qwq.icu
blog-ten-sage-23.vercel.app
blog-git-master-notevenaneko.vercel.app
blog-notevenaneko.vercel.app
www.qwq.icu