mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
refactor app struct
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import PostCard from 'app/blog/post-card';
|
||||
import PostCardLoading from 'app/blog/post-card-loading';
|
||||
import PostCard from 'components/pages/blog/post-card';
|
||||
import PostCardLoading from 'components/pages/blog/post-card-loading';
|
||||
import Pagination from 'components/rua/rua-pagination';
|
||||
import { getPostListPath, postLists, PostPerPage } from 'lib/posts';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import PostCardLoading from './post-card-loading';
|
||||
import PostCardLoading from 'components/pages/blog/post-card-loading';
|
||||
|
||||
const Loading = () => {
|
||||
const num = Array(4).fill(1);
|
||||
|
@ -1,8 +1,8 @@
|
||||
import PostCard from './post-card';
|
||||
import PostCardLoading from './post-card-loading';
|
||||
import PostCard from 'components/pages/blog/post-card';
|
||||
import PostCardLoading from 'components/pages/blog/post-card-loading';
|
||||
import Pagination from 'components/rua/rua-pagination';
|
||||
import { PostPerPage, postLists } from 'lib/posts';
|
||||
import { Fragment, Suspense } from 'react';
|
||||
import Pagination from 'components/rua/rua-pagination';
|
||||
|
||||
export default async function Page() {
|
||||
const allPosts = await postLists();
|
||||
|
@ -1,62 +0,0 @@
|
||||
import React, { memo } from 'react';
|
||||
import clsx from 'clsx';
|
||||
|
||||
const PostCardLoading = () => {
|
||||
return (
|
||||
<article
|
||||
className={clsx(
|
||||
'rounded-xl py-4 px-5 md:p-7 ',
|
||||
'hover:bg-sky-100 hover:bg-opacity-50',
|
||||
'dark:hover:bg-rua-gray-800 dark:hover:bg-opacity-100',
|
||||
'flex justify-between text-gray-800 ',
|
||||
'mb-4 dark:text-gray-200',
|
||||
'flex-col',
|
||||
)}
|
||||
>
|
||||
<div className="flex justify-between">
|
||||
<h2
|
||||
className={clsx(
|
||||
'w-96 bg-gray-300 h-7 animate-pulse',
|
||||
'mb-4 text-3xl font-semibold font-Barlow',
|
||||
'rounded-lg dark:bg-gray-500',
|
||||
)}
|
||||
></h2>
|
||||
|
||||
<div
|
||||
className={clsx(
|
||||
'hidden animate-pulse h-5 bg-gray-300',
|
||||
'dark:bg-gray-500 lg:block w-24',
|
||||
'rounded-lg',
|
||||
)}
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-between">
|
||||
<div className="flex items-center text-sm">
|
||||
<div
|
||||
className={clsx(
|
||||
'mr-4 last:mr-0 w-9 animate-pulse h-5',
|
||||
'rounded-lg bg-gray-300 dark:bg-gray-500',
|
||||
)}
|
||||
></div>
|
||||
<div
|
||||
className={clsx(
|
||||
'mr-4 last:mr-0 w-9 animate-pulse h-5',
|
||||
'rounded-lg bg-gray-300 dark:bg-gray-500',
|
||||
)}
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={clsx(
|
||||
'hidden animate-pulse h-5 bg-gray-300',
|
||||
'dark:bg-gray-500 lg:block w-24',
|
||||
'rounded-lg lg:hidden',
|
||||
)}
|
||||
></div>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(PostCardLoading);
|
@ -1,54 +0,0 @@
|
||||
import Link from 'next/link';
|
||||
import { Post } from 'types';
|
||||
import clsx from 'clsx';
|
||||
import { memo } from 'react';
|
||||
|
||||
interface Props {
|
||||
post: Post;
|
||||
}
|
||||
|
||||
const PostCard = ({ post }: Props) => {
|
||||
return (
|
||||
<>
|
||||
<Link href={`/p/${post.slug}`} passHref>
|
||||
<article
|
||||
className={clsx(
|
||||
'rounded-xl py-4 px-5 md:p-7 ',
|
||||
'hover:bg-sky-100 hover:bg-opacity-50',
|
||||
// 'hover:bg-rua-gray-100 hover:bg-opacity-10',
|
||||
'dark:hover:bg-rua-gray-800 dark:hover:bg-opacity-100',
|
||||
'flex justify-between text-gray-800 ',
|
||||
'mb-4 dark:text-gray-200',
|
||||
'flex-col',
|
||||
)}
|
||||
>
|
||||
<div className="flex justify-between">
|
||||
<h2 className="mb-4 text-3xl font-semibold font-Barlow">
|
||||
{post.title}
|
||||
</h2>
|
||||
|
||||
<div className="hidden lg:block">{post.date}</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-between">
|
||||
<div className="flex items-center text-sm">
|
||||
{Array.isArray(post.tags) ? (
|
||||
post.tags.map((tag) => (
|
||||
<div key={tag} className="mr-4 last:mr-0">
|
||||
{tag}
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<div className="mr-4 last:mr-0">{post.tags}</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="lg:hidden">{post.date}</div>
|
||||
</div>
|
||||
</article>
|
||||
</Link>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(PostCard);
|
@ -1,40 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
import useMounted from 'lib/hooks/use-mounted';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { memo } from 'react';
|
||||
import { FiMoon, FiSun } from 'react-icons/fi';
|
||||
|
||||
const DarkModeBtn = () => {
|
||||
const { mounted } = useMounted();
|
||||
const { systemTheme, theme, setTheme } = useTheme();
|
||||
const currentTheme = theme === 'system' ? systemTheme : theme;
|
||||
|
||||
if (!mounted) {
|
||||
return (
|
||||
<button>
|
||||
<div
|
||||
className={clsx(
|
||||
'w-5 h-5 rounded-md animate-pulse',
|
||||
'bg-gray-300 dark:bg-gray-500',
|
||||
)}
|
||||
></div>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{currentTheme === 'dark' ? (
|
||||
<button>
|
||||
<FiSun className="w-5 h-5" onClick={() => setTheme('light')} />
|
||||
</button>
|
||||
) : (
|
||||
<button>
|
||||
<FiMoon className="w-5 h-5" onClick={() => setTheme('dark')} />
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(DarkModeBtn);
|
@ -1,45 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
import { memo } from 'react';
|
||||
import { FiGithub } from 'react-icons/fi';
|
||||
|
||||
const nowDay = new Date().getFullYear();
|
||||
|
||||
const Footer = () => {
|
||||
return (
|
||||
<>
|
||||
<footer className="max-w-6xl px-4 mx-auto xl:px-0">
|
||||
<div className="h-[2px] bg-slate-500"></div>
|
||||
|
||||
<div
|
||||
className={clsx(
|
||||
'flex items-center flex-col',
|
||||
'justify-between py-4',
|
||||
'lg:flex-row',
|
||||
)}
|
||||
>
|
||||
<div className="mb-1">© {nowDay} Powered by Next.js 💙 xfy</div>
|
||||
<div className="mb-1">
|
||||
<a
|
||||
href="https://github.com/DefectingCat"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<FiGithub />
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<a
|
||||
href="https://beian.miit.gov.cn/"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
皖ICP备17017808号-2
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(Footer);
|
@ -1,6 +1,5 @@
|
||||
import GistsCode from 'app/gists/gists-code';
|
||||
import clsx from 'clsx';
|
||||
import LinkAnchor from 'components/mdx/link-anchor';
|
||||
import GistsCode from 'components/pages/gists/gists-code';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import { getSignalGist } from 'lib/fetcher';
|
||||
@ -8,7 +7,6 @@ import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
import { notFound } from 'next/navigation';
|
||||
import avatar from 'public/images/img/avatar.svg';
|
||||
import GistsCodeSkeleton from 'app/gists/gists-code-skeleton';
|
||||
|
||||
export const revalidate = 600;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import GistsCodeSkeleton from 'app/gists/gists-code-skeleton';
|
||||
import GistsCodeSkeleton from 'components/pages/gists/gists-code-skeleton';
|
||||
import clsx from 'clsx';
|
||||
|
||||
const loading = () => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import FileContent from 'components/pages/gists/file-content';
|
||||
import Pagination from 'components/rua/rua-pagination';
|
||||
import { getGists } from 'lib/fetcher';
|
||||
import { notFound } from 'next/navigation';
|
||||
import FileContent from '../file-content';
|
||||
import Pagination from 'components/rua/rua-pagination';
|
||||
|
||||
export const revalidate = 600;
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
|
||||
export default function FileContentLoading() {
|
||||
return (
|
||||
<div className={clsx('pb-4')}>
|
||||
{/* Username */}
|
||||
<h1
|
||||
className={clsx(
|
||||
'md:text-lg h-7 bg-gray-200',
|
||||
'animate-pulse w-48 rounded-lg',
|
||||
'dark:bg-rua-gray-700',
|
||||
'mb-2',
|
||||
)}
|
||||
></h1>
|
||||
{/* last active */}
|
||||
<div
|
||||
className={clsx(
|
||||
'h-4 w-72 bg-gray-200',
|
||||
'animate-pulse rounded-lg',
|
||||
'dark:bg-rua-gray-700',
|
||||
)}
|
||||
></div>
|
||||
{/* code block */}
|
||||
<div
|
||||
className={clsx(
|
||||
'w-full h-[488px] rounded-lg',
|
||||
'animate-pulse dark:bg-rua-gray-700',
|
||||
'mt-3 bg-gray-200',
|
||||
)}
|
||||
></div>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
import LinkAnchor from 'components/mdx/link-anchor';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import Link from 'next/link';
|
||||
import { memo } from 'react';
|
||||
import GistsCode from './gists-code';
|
||||
import { GistData } from 'types';
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
type Props = {
|
||||
gists: GistData[];
|
||||
};
|
||||
|
||||
const FileContent = ({ gists }: Props) => {
|
||||
return (
|
||||
<>
|
||||
<div className="overflow-hidden">
|
||||
{gists.map((g) => (
|
||||
<div key={g.id}>
|
||||
{Object.keys(g.files).map((f) => (
|
||||
<div key={g.files[f]?.raw_url} className="pb-4 ">
|
||||
{/* Username and file name */}
|
||||
<h1 className="md:text-lg">
|
||||
{g.login} /
|
||||
<Link href={`/g/${g.id}`}>
|
||||
<LinkAnchor external={false}>
|
||||
{g.files[f]?.filename}
|
||||
</LinkAnchor>
|
||||
</Link>
|
||||
</h1>
|
||||
{/* Time */}
|
||||
<p className="text-gray-400">
|
||||
Last active: {dayjs(g.updated_at).fromNow()}
|
||||
</p>
|
||||
{/* Description */}
|
||||
<p className="text-gray-500">{g.description}</p>
|
||||
|
||||
{g.files[f] && <GistsCode file={g!.files[f]!} />}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(FileContent);
|
@ -1,77 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
import { memo } from 'react';
|
||||
import styles from './gists-code.module.css';
|
||||
|
||||
const bodyClass = clsx(
|
||||
'rounded-lg',
|
||||
'h-4 bg-gray-300',
|
||||
'mb-2 last:mb-0 animate-pulse',
|
||||
'dark:bg-rua-gray-600',
|
||||
);
|
||||
const allLength = [
|
||||
500, 400, 300, 200, 332, 402, 105, 399, 501, 285, 378, 123, 325, 456,
|
||||
];
|
||||
|
||||
const GistsCode = () => {
|
||||
return (
|
||||
<>
|
||||
<div className={styles.wrapper}>
|
||||
<div className="h-[30px] bg-[#f6f8fa] dark:bg-[hsl(220,13%,18%)] flex">
|
||||
<div className="flex items-center h-full mx-3">
|
||||
<div
|
||||
className={clsx(
|
||||
'box-border inline-block',
|
||||
'w-[13px] h-[13px] mr-2',
|
||||
'rounded-full bg-[#ce5347]',
|
||||
)}
|
||||
></div>
|
||||
<div
|
||||
className={clsx(
|
||||
'box-border inline-block',
|
||||
'w-[13px] h-[13px] mr-2',
|
||||
'rounded-full bg-[#d6a243]',
|
||||
)}
|
||||
></div>
|
||||
<div
|
||||
className={clsx(
|
||||
'box-border inline-block',
|
||||
'w-[13px] h-[13px]',
|
||||
'rounded-full bg-[#58a942]',
|
||||
)}
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={clsx(
|
||||
'px-4 bg-white',
|
||||
'leading-[30px]',
|
||||
'dark:bg-[hsl(220,13%,18%)] dark:border-b dark:border-b-[rgb(128,203,196)]',
|
||||
'overflow-hidden whitespace-nowrap overflow-ellipsis',
|
||||
'flex items-center',
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className={clsx(
|
||||
'bg-gray-300 animate-pulse',
|
||||
'w-20 h-4 block rounded',
|
||||
'dark:bg-rua-gray-600',
|
||||
)}
|
||||
></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<pre>
|
||||
{allLength.map((item, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className={bodyClass}
|
||||
style={{ width: item }}
|
||||
></div>
|
||||
))}
|
||||
</pre>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(GistsCode);
|
@ -1,16 +0,0 @@
|
||||
.wrapper {
|
||||
@apply overflow-hidden rounded-lg;
|
||||
@apply mb-8 shadow-lg;
|
||||
font-size: 16px;
|
||||
/* box-shadow: 0 13px 27px -5px rgb(50 50 93 / 25%),
|
||||
0 8px 16px -8px rgb(0 0 0 / 30%), 0 -6px 16px -6px rgb(0 0 0 / 3%); */
|
||||
}
|
||||
|
||||
.wrapper pre {
|
||||
margin: unset;
|
||||
border-radius: unset;
|
||||
}
|
||||
|
||||
.wrapper .loading span {
|
||||
margin: unset;
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
import rehypePrism from '@mapbox/rehype-prism';
|
||||
import clsx from 'clsx';
|
||||
import { createElement, Fragment, memo } from 'react';
|
||||
import rehypeReact from 'rehype-react';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import remarkParse from 'remark-parse';
|
||||
import remarkRehype from 'remark-rehype';
|
||||
import { GistsFile } from 'types';
|
||||
import { unified } from 'unified';
|
||||
import styles from './gists-code.module.css';
|
||||
|
||||
interface Props {
|
||||
file: GistsFile;
|
||||
showFileName?: boolean;
|
||||
}
|
||||
|
||||
const GistsCode = ({ file, showFileName = false }: Props) => {
|
||||
const fileContent = showFileName
|
||||
? file.content
|
||||
: file.content?.split('\n').slice(0, 20).join('\n');
|
||||
const code = unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkRehype)
|
||||
.use(remarkGfm)
|
||||
.use(rehypePrism, { ignoreMissing: true })
|
||||
.use(rehypeReact, {
|
||||
createElement,
|
||||
Fragment,
|
||||
})
|
||||
.processSync(`\`\`\`${file.language ?? ''}\n${fileContent}`).result;
|
||||
|
||||
return (
|
||||
<>
|
||||
{showFileName ? (
|
||||
<div className={styles.wrapper}>
|
||||
<div className="h-[30px] bg-[#f6f8fa] dark:bg-[hsl(220,13%,18%)] flex">
|
||||
<div className="flex items-center h-full mx-3">
|
||||
<div
|
||||
className={clsx(
|
||||
'box-border inline-block',
|
||||
'w-[13px] h-[13px] mr-2',
|
||||
'rounded-full bg-[#ce5347]',
|
||||
)}
|
||||
></div>
|
||||
<div
|
||||
className={clsx(
|
||||
'box-border inline-block',
|
||||
'w-[13px] h-[13px] mr-2',
|
||||
'rounded-full bg-[#d6a243]',
|
||||
)}
|
||||
></div>
|
||||
<div
|
||||
className={clsx(
|
||||
'box-border inline-block',
|
||||
'w-[13px] h-[13px]',
|
||||
'rounded-full bg-[#58a942]',
|
||||
)}
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={clsx(
|
||||
'px-4 bg-white',
|
||||
'leading-[30px]',
|
||||
'dark:bg-[hsl(220,13%,18%)] dark:border-b dark:border-b-[rgb(128,203,196)]',
|
||||
'overflow-hidden whitespace-nowrap overflow-ellipsis',
|
||||
)}
|
||||
>
|
||||
{file.filename}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>{code}</div>
|
||||
</div>
|
||||
) : (
|
||||
<div>{code}</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(GistsCode);
|
@ -1,50 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
// import GistsCode from './gists-code';
|
||||
|
||||
const GistSkeleton = () => {
|
||||
return (
|
||||
<>
|
||||
<main className="max-w-5xl px-4 mx-auto lg:px-0">
|
||||
<div className="pb-4 text-sm">
|
||||
<div className="flex items-center py-1 ">
|
||||
<div
|
||||
className={clsx(
|
||||
'w-8 h-8 rounded-full',
|
||||
'animate-pulse bg-gray-300',
|
||||
'dark:bg-gray-400 ',
|
||||
)}
|
||||
></div>
|
||||
<h1
|
||||
className={clsx(
|
||||
'ml-2 overflow-hidden text-xl',
|
||||
'whitespace-nowrap overflow-ellipsis',
|
||||
'w-[234px] animate-pulse bg-gray-300',
|
||||
'h-6 rounded-lg',
|
||||
'dark:bg-gray-400',
|
||||
)}
|
||||
></h1>
|
||||
</div>
|
||||
|
||||
<p
|
||||
className={clsx(
|
||||
'ml-10 text-gray-400',
|
||||
'w-48 h-4 animate-pulse bg-gray-300',
|
||||
'rounded-lg',
|
||||
'dark:bg-gray-400',
|
||||
)}
|
||||
></p>
|
||||
|
||||
<div className="py-4">
|
||||
<p className="pb-2 text-lg text-gray-500">
|
||||
<span className={'w-16 animate-pulse'}></span>
|
||||
</p>
|
||||
|
||||
{/* <GistsCode /> */}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default GistSkeleton;
|
@ -1,7 +1,7 @@
|
||||
import UserInfo from 'components/pages/gists/user-info';
|
||||
import UserInfoLoading from 'components/pages/gists/user-info-skeleton';
|
||||
import { Metadata } from 'next';
|
||||
import { ReactNode, Suspense } from 'react';
|
||||
import UserInfo from './user-info';
|
||||
import UserInfoLoading from './user-info-skeleton';
|
||||
|
||||
export const revalidate = 600;
|
||||
export const metadata: Metadata = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import FileContentLoading from './file-content-skeleton';
|
||||
import FileContentLoading from 'components/pages/gists/file-content-skeleton';
|
||||
|
||||
export default function Loading() {
|
||||
const num = Array(3).fill(null);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import FileContent from 'components/pages/gists/file-content';
|
||||
import Pagination from 'components/rua/rua-pagination';
|
||||
import { getGists } from 'lib/fetcher';
|
||||
import { notFound } from 'next/navigation';
|
||||
import Pagination from 'components/rua/rua-pagination';
|
||||
import FileContent from './file-content';
|
||||
|
||||
export const revalidate = 600;
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
import { FiLink, FiMail, FiTwitter } from 'react-icons/fi';
|
||||
|
||||
const UserInfoLoading = () => {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={clsx(
|
||||
'flex md:items-center flex-1',
|
||||
'max-w-[280px] md:block',
|
||||
'mb-4 flex-col md:flex-row',
|
||||
)}
|
||||
>
|
||||
<div className="flex md:flex-col">
|
||||
<div
|
||||
className={clsx(
|
||||
'w-16 h-16 mr-4 overflow-hidden',
|
||||
'md:w-72 md:h-72 bg-gray-200 rounded-full',
|
||||
'animate-pulse dark:bg-rua-gray-800',
|
||||
)}
|
||||
></div>
|
||||
|
||||
<div>
|
||||
<h1
|
||||
className={clsx(
|
||||
'text-xl font-bold font-Barlow md:text-2xl w-44',
|
||||
'animate-pulse h-6 rounded-lg',
|
||||
'bg-gray-200 dark:bg-rua-gray-800',
|
||||
'my-2',
|
||||
)}
|
||||
></h1>
|
||||
|
||||
<h2
|
||||
className={clsx(
|
||||
'text-xl text-gray-400 font-Barlow md:text-2xl',
|
||||
'animate-pulse h-5 rounded-lg w-32',
|
||||
'bg-gray-200 dark:bg-rua-gray-800',
|
||||
)}
|
||||
></h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={clsx(
|
||||
'my-4 w-44 h-4 rounded-lg animate-pulse',
|
||||
'bg-gray-200 dark:bg-rua-gray-800',
|
||||
)}
|
||||
></div>
|
||||
|
||||
<div>
|
||||
<div className="flex items-center mb-1 animate-pulse">
|
||||
<FiMail className="mr-2" />
|
||||
<div className="w-40 h-4 bg-gray-200 rounded-lg"></div>
|
||||
</div>
|
||||
<div className="flex items-center mb-1 animate-pulse">
|
||||
<FiLink className="mr-2" />
|
||||
<div className="w-40 h-4 bg-gray-200 rounded-lg"></div>
|
||||
</div>
|
||||
<div className="flex items-center mb-1 animate-pulse">
|
||||
<FiTwitter className="mr-2" />
|
||||
<div className="w-40 h-4 bg-gray-200 rounded-lg"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default UserInfoLoading;
|
@ -1,80 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
import { getUser } from 'lib/fetcher';
|
||||
import Image from 'next/image';
|
||||
import avatar from 'public/images/img/avatar.svg';
|
||||
import { FiLink, FiMail, FiTwitter } from 'react-icons/fi';
|
||||
|
||||
const UserInfo = async () => {
|
||||
const user = await getUser();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={clsx(
|
||||
'flex md:items-center flex-1',
|
||||
'max-w-[280px] md:block',
|
||||
'mb-4 flex-col md:flex-row',
|
||||
)}
|
||||
>
|
||||
<div className="flex md:flex-col">
|
||||
<div
|
||||
className={clsx(
|
||||
'w-16 h-16 mr-4 overflow-hidden',
|
||||
'md:w-auto h-auto',
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
src={avatar}
|
||||
alt="Avatar"
|
||||
priority
|
||||
className="rounded-full"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h1 className="text-xl font-bold font-Barlow md:text-2xl">
|
||||
{user.name}
|
||||
</h1>
|
||||
|
||||
<h2 className="text-xl text-gray-400 font-Barlow md:text-2xl">
|
||||
{user.login}
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="my-4">{user.bio}</div>
|
||||
|
||||
<div>
|
||||
<div className="flex items-center mb-1">
|
||||
<FiMail className="mr-2" />
|
||||
<span>
|
||||
<a href={`mailto:${user.email}`}>{user.email}</a>
|
||||
</span>
|
||||
</div>
|
||||
{user.blog && (
|
||||
<div className="flex items-center mb-1">
|
||||
<FiLink className="mr-2" />
|
||||
<a href={user.blog} target="_blank" rel="noreferrer">
|
||||
{user.blog}
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
{user.twitter_username && (
|
||||
<div className="flex items-center mb-1">
|
||||
<FiTwitter className="mr-2" />
|
||||
<a
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
href={`https://twitter.com/${user.twitter_username}`}
|
||||
>
|
||||
@{user.twitter_username}
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default UserInfo;
|
@ -1,15 +1,15 @@
|
||||
import '@docsearch/css/dist/style.css';
|
||||
import clsx from 'clsx';
|
||||
import BackToTop from 'components/common/back-to-top';
|
||||
import Footer from 'components/pages/footer';
|
||||
import HeadBar from 'components/pages/nav-bar';
|
||||
import RUAThemeProvider from 'components/pages/theme-provider';
|
||||
import fonts from 'lib/fonts';
|
||||
import { Metadata } from 'next';
|
||||
import 'styles/globals.css';
|
||||
import 'styles/prism-one-dark.css';
|
||||
import 'styles/prism-one-light.css';
|
||||
import 'styles/rua.css';
|
||||
import Footer from './footer';
|
||||
import HeadBar from './nav-bar';
|
||||
import RUAThemeProvider from './theme-provider';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'RUA',
|
||||
|
164
app/nav-bar.tsx
164
app/nav-bar.tsx
@ -1,164 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { DocSearch } from '@docsearch/react';
|
||||
import clsx from 'clsx';
|
||||
import Link from 'next/link';
|
||||
import { memo, useEffect, useState } from 'react';
|
||||
import { FiMenu } from 'react-icons/fi';
|
||||
import DarkModeBtn from './dark-mode-btn';
|
||||
|
||||
const txtMenu = [
|
||||
{
|
||||
id: 0,
|
||||
name: 'Home',
|
||||
path: '/',
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: 'Blog',
|
||||
path: '/blog',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Projects',
|
||||
path: '/projects',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Gists',
|
||||
path: '/gists',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'About',
|
||||
path: '/about',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Check element's id and it's parents
|
||||
* @param el
|
||||
* @returns
|
||||
*/
|
||||
const parentIdChecker = (el: HTMLElement | null): boolean => {
|
||||
if (!el) return false;
|
||||
if (!el?.id) return parentIdChecker(el.parentElement);
|
||||
return (
|
||||
!!['menu', 'menu-icon'].filter((item) => item === el.id).length ||
|
||||
parentIdChecker(el.parentElement)
|
||||
);
|
||||
};
|
||||
|
||||
const HeadBar = () => {
|
||||
const [showMenu, setShowMenu] = useState(false);
|
||||
const handleClick = () => {
|
||||
setShowMenu((showMenu) => !showMenu);
|
||||
};
|
||||
|
||||
const [mounted, setMounted] = useState(false);
|
||||
useEffect(() => setMounted(true), []);
|
||||
|
||||
/**
|
||||
* Click anywhere to close nav on mobile.
|
||||
*/
|
||||
const handleCloseNav = (e: TouchEvent) => {
|
||||
parentIdChecker(e.target as HTMLElement) || setShowMenu(false);
|
||||
};
|
||||
useEffect(() => {
|
||||
window.addEventListener('touchstart', handleCloseNav);
|
||||
return () => {
|
||||
window.removeEventListener('touchstart', handleCloseNav);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<header
|
||||
className={clsx(
|
||||
'flex justify-between mx-auto',
|
||||
'max-w-6xl p-4 xl:px-0 h-[84px]',
|
||||
'items-center relative',
|
||||
)}
|
||||
>
|
||||
<Link href="/">
|
||||
<span
|
||||
className={clsx(
|
||||
'font-semibold',
|
||||
'text-3xl tracking-widest',
|
||||
'select-none',
|
||||
)}
|
||||
>
|
||||
RUA!
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
<FiMenu
|
||||
className="cursor-pointer w-7 h-7 md:hidden"
|
||||
onClick={handleClick}
|
||||
id="menu-icon"
|
||||
/>
|
||||
|
||||
<nav
|
||||
className={clsx(
|
||||
'text-lg md:block',
|
||||
'bg-white rounded-md',
|
||||
'dark:bg-rua-gray-800',
|
||||
'absolute md:static',
|
||||
'p-5 right-6 top-14',
|
||||
'md:bg-transparent md:p-[unset]',
|
||||
'md:right-[unset] md:top-[unset]',
|
||||
'w-1/3 md:w-auto z-20',
|
||||
'md:dark:bg-transparent',
|
||||
showMenu || 'hidden',
|
||||
)}
|
||||
id="menu"
|
||||
>
|
||||
<ul className={clsx('flex flex-col ', 'md:flex-row md:items-center')}>
|
||||
{txtMenu.map((m) => (
|
||||
<li
|
||||
key={m.id}
|
||||
onClick={handleClick}
|
||||
className={clsx(
|
||||
'mb-2 last:mb-0 md:mb-0',
|
||||
'md:mr-4 md:last:mr-0',
|
||||
)}
|
||||
>
|
||||
<Link href={m.path}>{m.name}</Link>
|
||||
</li>
|
||||
))}
|
||||
<li
|
||||
className={clsx(
|
||||
'mb-2 last:mb-0 md:mb-0',
|
||||
'md:mr-4 md:last:mr-0',
|
||||
'flex items-center',
|
||||
)}
|
||||
>
|
||||
<DarkModeBtn />
|
||||
</li>
|
||||
<li className="DocSearch-wrapper">
|
||||
{mounted ? (
|
||||
<DocSearch
|
||||
appId={process.env.NEXT_PUBLIC_ALGOLIA_APP_ID ?? ''}
|
||||
indexName="RUA"
|
||||
apiKey={
|
||||
process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_ADMIN_KEY ?? ''
|
||||
}
|
||||
placeholder="Search..."
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
className={clsx(
|
||||
'w-[164.453px] h-[30px]',
|
||||
'bg-[#ebedf0] rounded-[40px] animate-pulse',
|
||||
)}
|
||||
></div>
|
||||
)}
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(HeadBar);
|
@ -1,7 +1,7 @@
|
||||
import clsx from 'clsx';
|
||||
import dynamic from 'next/dynamic';
|
||||
import Image from 'next/image';
|
||||
import styles from 'styles/index/index.module.css';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
const HomeModel = dynamic(() => import('../components/models/home-model'));
|
||||
|
||||
|
@ -1,127 +0,0 @@
|
||||
import { BiPlanet } from 'react-icons/bi';
|
||||
import { HiPhoto } from 'react-icons/hi2';
|
||||
import {
|
||||
PiGitlabLogoSimpleDuotone,
|
||||
PiPlanetDuotone,
|
||||
PiPlanetLight,
|
||||
} from 'react-icons/pi';
|
||||
import {
|
||||
SiNextdotjs,
|
||||
SiRedux,
|
||||
SiThreedotjs,
|
||||
SiTsnode,
|
||||
SiVim,
|
||||
} from 'react-icons/si';
|
||||
import { TbBrandRust } from 'react-icons/tb';
|
||||
import { VscGithubInverted } from 'react-icons/vsc';
|
||||
|
||||
export const iconMap = {
|
||||
gitlab: <PiGitlabLogoSimpleDuotone />,
|
||||
nextjs: <SiNextdotjs />,
|
||||
github: <VscGithubInverted />,
|
||||
vim: <SiVim />,
|
||||
tsnode: <SiTsnode />,
|
||||
three: <SiThreedotjs />,
|
||||
photos: <HiPhoto />,
|
||||
redux: <SiRedux />,
|
||||
venus: <BiPlanet />,
|
||||
pluto: <PiPlanetDuotone />,
|
||||
mercury: <PiPlanetLight />,
|
||||
rust: <TbBrandRust />,
|
||||
};
|
||||
|
||||
export type Project = {
|
||||
icon?: keyof typeof iconMap;
|
||||
name: string;
|
||||
description: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export const projects: Project[] = [
|
||||
{
|
||||
icon: 'venus',
|
||||
name: 'Venus',
|
||||
description: 'A tiny GUI for network tool.',
|
||||
url: 'https://github.com/DefectingCat/venus',
|
||||
},
|
||||
{
|
||||
icon: 'pluto',
|
||||
name: 'Pluto',
|
||||
description: 'Tcping tool',
|
||||
url: 'https://github.com/DefectingCat/pluto',
|
||||
},
|
||||
{
|
||||
icon: 'mercury',
|
||||
name: 'Mercury',
|
||||
description: 'A network tool backend',
|
||||
url: 'https://github.com/DefectingCat/mercury',
|
||||
},
|
||||
{
|
||||
icon: 'three',
|
||||
name: '3d-globe',
|
||||
description: 'A 3d globe made by three.js.',
|
||||
url: 'https://github.com/DefectingCat/3d-globe',
|
||||
},
|
||||
{
|
||||
icon: 'nextjs',
|
||||
name: 'Blog',
|
||||
description: 'This site.',
|
||||
url: 'https://github.com/DefectingCat/DefectingCat.github.io',
|
||||
},
|
||||
{
|
||||
icon: 'tsnode',
|
||||
name: 'Simply FaaS',
|
||||
description: 'A simply FaaS built with Node.js',
|
||||
url: 'https://github.com/DefectingCat/simply-fass',
|
||||
},
|
||||
{
|
||||
icon: 'tsnode',
|
||||
name: 'boring-avatars-services',
|
||||
description: 'Random avatars.',
|
||||
url: 'https://github.com/DefectingCat/boring-avatars-services',
|
||||
},
|
||||
{
|
||||
icon: 'tsnode',
|
||||
name: 'RUA DDNS',
|
||||
description: 'DDNS Script for DNSPod',
|
||||
url: 'https://github.com/DefectingCat/rua-ddns',
|
||||
},
|
||||
{
|
||||
icon: 'rust',
|
||||
name: 'Candy',
|
||||
description: 'Tiny web server.',
|
||||
url: 'https://github.com/DefectingCat/candy',
|
||||
},
|
||||
{
|
||||
icon: 'vim',
|
||||
name: 'Dotfiles',
|
||||
description: 'Some dotfiles.',
|
||||
url: 'https://github.com/DefectingCat/dotfiles',
|
||||
},
|
||||
{
|
||||
icon: 'redux',
|
||||
name: 'RUA-Context',
|
||||
description: 'A global store for React.',
|
||||
url: 'https://github.com/rua-plus/rua-context',
|
||||
},
|
||||
{
|
||||
icon: 'three',
|
||||
name: 'RUA-Three',
|
||||
description: 'A three.js hooks for React.',
|
||||
url: 'https://github.com/rua-plus/rua-three',
|
||||
},
|
||||
];
|
||||
export const selfHosts: Project[] = [
|
||||
{
|
||||
icon: 'gitlab',
|
||||
name: 'Gitlab',
|
||||
description: 'Selfhost git.',
|
||||
url: 'https://git.rua.plus/',
|
||||
},
|
||||
{
|
||||
icon: 'photos',
|
||||
name: 'Photos',
|
||||
description: 'Some photos.',
|
||||
url: 'https://photos.rua.plus/',
|
||||
},
|
||||
];
|
@ -1,7 +1,7 @@
|
||||
import clsx from 'clsx';
|
||||
import { projects, selfHosts } from 'components/pages/projects/content';
|
||||
import PojectCardSkeleton from 'components/pages/projects/project-card-skeleton';
|
||||
import { Metadata } from 'next';
|
||||
import { projects, selfHosts } from './content';
|
||||
import PojectCardSkeleton from './project-card-skeleton';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'RUA - Projects',
|
||||
|
@ -1,7 +1,11 @@
|
||||
import clsx from 'clsx';
|
||||
import ProjectCard from './project-card';
|
||||
import {
|
||||
iconMap,
|
||||
projects,
|
||||
selfHosts,
|
||||
} from 'components/pages/projects/content';
|
||||
import ProjectCard from 'components/pages/projects/project-card';
|
||||
import { Metadata } from 'next';
|
||||
import { projects, iconMap, selfHosts } from './content';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'RUA - Projects',
|
||||
|
@ -1,43 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
import { VscGithubInverted } from 'react-icons/vsc';
|
||||
|
||||
const PojectCardSkeleton = () => {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={clsx(
|
||||
'py-3 px-4 rounded-lg bg-slate-100',
|
||||
'hover:bg-slate-200',
|
||||
'transition-all duration-300',
|
||||
'flex items-center cursor-pointer',
|
||||
'justify-between dark:bg-rua-gray-800',
|
||||
'hover:dark:bg-rua-gray-700',
|
||||
)}
|
||||
>
|
||||
<VscGithubInverted className="w-8 h-8" />
|
||||
|
||||
<a className="w-[calc(100%_-_40px)]" target="_blank" rel="noreferrer">
|
||||
<h2
|
||||
className={clsx(
|
||||
'text-xl overflow-hidden',
|
||||
'text-ellipsis whitespace-nowrap',
|
||||
'h-6 w-[100px] animate-pulse',
|
||||
'bg-gray-300 rounded-lg',
|
||||
)}
|
||||
></h2>
|
||||
<span
|
||||
className={clsx(
|
||||
'overflow-hidden break-keep text-ellipsis',
|
||||
'whitespace-nowrap inline-block',
|
||||
'w-[inherit] mt-1',
|
||||
'h-5 w-[300px] animate-pulse',
|
||||
'bg-gray-300 rounded-lg',
|
||||
)}
|
||||
></span>
|
||||
</a>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default PojectCardSkeleton;
|
@ -1,62 +0,0 @@
|
||||
import clsx from 'clsx';
|
||||
import { Children, cloneElement, isValidElement, ReactElement } from 'react';
|
||||
import { VscGithubInverted } from 'react-icons/vsc';
|
||||
import { Project } from './content';
|
||||
|
||||
type ProjectCardProps = {
|
||||
project: Project;
|
||||
icon?: ReactElement<{ className?: string }>;
|
||||
};
|
||||
|
||||
const ProjectCard = ({ project, icon }: ProjectCardProps) => {
|
||||
const Icon = Children.map(icon, (child) => {
|
||||
if (!isValidElement(child)) return child;
|
||||
return cloneElement(child, {
|
||||
className: 'w-8 h-8',
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={clsx(
|
||||
'py-3 px-4 rounded-lg bg-slate-100',
|
||||
'hover:bg-slate-200',
|
||||
'transition-all duration-300',
|
||||
'flex items-center cursor-pointer',
|
||||
'justify-between dark:bg-rua-gray-800',
|
||||
'hover:dark:bg-rua-gray-700',
|
||||
)}
|
||||
>
|
||||
{Icon ? Icon : <VscGithubInverted className="w-8 h-8" />}
|
||||
|
||||
<a
|
||||
href={project.url}
|
||||
className="w-[calc(100%_-_40px)]"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<h2
|
||||
className={clsx(
|
||||
'text-xl overflow-hidden',
|
||||
'text-ellipsis whitespace-nowrap',
|
||||
)}
|
||||
>
|
||||
{project.name}
|
||||
</h2>
|
||||
<span
|
||||
className={clsx(
|
||||
'overflow-hidden break-keep text-ellipsis',
|
||||
'whitespace-nowrap inline-block',
|
||||
'w-[inherit]',
|
||||
)}
|
||||
>
|
||||
{project.description}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProjectCard;
|
@ -1,22 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { ThemeProvider } from 'next-themes';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
export default function RUAThemeProvider({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
storageKey="rua-theme"
|
||||
themes={['light', 'dark']}
|
||||
enableSystem
|
||||
defaultTheme="system"
|
||||
>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user