This is a Next.js project bootstrapped with create-next-app
.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx
. The page auto-updates as you edit the file.
This project uses next/font
to automatically optimize and load Inter, a custom Google Font.
To learn more about Next.js, take a look at the following resources:
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
git remote -v 查看当前仓库源
git remote set-url --add origin https://gitee.com/BruceLluo/my-threads.git
npx create-next-app@latest ./
npm install @clerk/nextjs @uploadthing/react mongoose svix uploadthing tailwindcss-animate @clerk/theme
使用next router 路由组,这允许您将路线段和项目文件组织到逻辑组中,而不影响 URL 路径结构。还可以嵌套路由,多个layout
(auth)->sign-in->sign-out
[https://app.logo.com/dashboard/logo_4a0f393c-f0be-42c7-93f0-169ba515c728/your-logo-files]设置自己logo
[https://favicon.io/favicon-converter/] 生成icon
引入clerk组件
{/* clerk退出登录组件 */}
<div className='block md:hidden'>
<SignedIn>
<SignOutButton>
<div className='flex cursor-pointer'>
<Image
src='/assets/logout.svg'
alt='logout'
width={24}
height={24}
/>
</div>
</SignOutButton>
</SignedIn>
</div>
{/* clerk组织组件 */}
<OrganizationSwitcher
appearance={{
baseTheme: dark,
elements: {
organizationSwitcherTrigger: "py-2 px-4",
},
}}
/>
import { usePathname, useRouter } from "next/navigation";
useRouter,usePathname获取路由信息
AccountProfile.tsx
引入shadcn ui 创建表单
npx shadcn-ui@latest init
npx shadcn-ui@latest add form input textarea
引入react-hook-form进行表单校验
引入zod 进行ts声明数据类型校验
引入uploadthing进行头像等资源上传,免费2g
使用nextjs中的server action 实验版
函数在服务器运行,但是可以在客户端调用
user.actions.ts中连接mongoose数据库,mongoosedb network access 设置允许所有ip 0.0.0.0./0
使用next的revalidatePath重新验证数据,并更新页面内容
提交表单上传头像,数据插入数据库
onboarding 同步数据库数据
创建帖子,配置表单校验, 数据库model创建, thread action创建
首页展示帖子, 创建ThreadCard
帖子进行评论,展示回复贴子
个人资料页,资料tabs,帖子
npx shadcn-ui@latest add tabs
ThreadsTab
还有replies,tagged
api/webhook/clerk/route
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。