登录结合OpenWrite

This commit is contained in:
tangly1024.com
2024-09-24 18:19:48 +08:00
parent 32a113fbce
commit 964513b1e9
18 changed files with 244 additions and 24 deletions

View File

@@ -10,7 +10,8 @@ export default function ArticleInfo({ post }) {
return (
<div className='pt-10 pb-6 text-gray-400 text-sm'>
<i className='fa-regular fa-clock mr-1' />
Last update: {post.date?.start_date}
Last update:{' '}
{post.date?.start_date || post?.publishDay || post?.lastEditedDay}
</div>
)
}

View File

@@ -2,6 +2,7 @@ import Collapse from '@/components/Collapse'
import DarkModeButton from '@/components/DarkModeButton'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import { SignInButton, SignedOut, UserButton } from '@clerk/nextjs'
import { useRef, useState } from 'react'
import CONFIG from '../config'
import LogoBar from './LogoBar'
@@ -59,6 +60,8 @@ export default function Header(props) {
links = customMenu
}
const enableClerk = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
return (
<div id='top-nav' className={'fixed top-0 w-full z-20 ' + className}>
{/* PC端菜单 */}
@@ -79,6 +82,19 @@ export default function Header(props) {
{/* 右侧 */}
<div className='flex items-center gap-4'>
{/* 登录相关 */}
{enableClerk && (
<>
<SignedOut>
<SignInButton mode='modal'>
<button className='bg-green-500 hover:bg-green-600 text-white rounded-lg px-3 py-2'>
{locale.COMMON.SIGN_IN}
</button>
</SignInButton>
</SignedOut>
<UserButton />
</>
)}
<DarkModeButton className='text-sm items-center h-full hidden md:flex' />
<SearchInput className='hidden md:flex md:w-52 lg:w-72' />
{/* 折叠按钮、仅移动端显示 */}

View File

@@ -11,6 +11,7 @@ import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import { isBrowser } from '@/lib/utils'
import { getShortId } from '@/lib/utils/pageId'
import { SignIn, SignUp } from '@clerk/nextjs'
import dynamic from 'next/dynamic'
import Link from 'next/link'
import { useRouter } from 'next/router'
@@ -164,7 +165,7 @@ const LayoutBase = props => {
{/* 中间内容区域 */}
<div
id='center-wrapper'
className='dark:bg-hexo-black-gray flex flex-col justify-between w-full relative z-10 pt-14 min-h-screen'>
className='flex flex-col justify-between w-full relative z-10 pt-14 min-h-screen'>
<div
id='container-inner'
className={`w-full ${fullWidth ? 'px-5' : 'max-w-3xl px-3 lg:px-0'} justify-center mx-auto`}>
@@ -473,6 +474,58 @@ const LayoutTagIndex = props => {
)
}
/**
* 登录页面
* @param {*} props
* @returns
*/
const LayoutSignIn = props => {
const { post } = props
const enableClerk = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
return (
<>
<div className='grow mt-20'>
{/* clerk预置表单 */}
{enableClerk && (
<div className='flex justify-center py-6'>
<SignIn />
</div>
)}
<div id='article-wrapper'>
<NotionPage post={post} />
</div>
</div>
</>
)
}
/**
* 注册页面
* @param {*} props
* @returns
*/
const LayoutSignUp = props => {
const { post } = props
const enableClerk = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
return (
<>
<div className='grow mt-20'>
{/* clerk预置表单 */}
{enableClerk && (
<div className='flex justify-center py-6'>
<SignUp />
</div>
)}
<div id='article-wrapper'>
<NotionPage post={post} />
</div>
</div>
</>
)
}
export {
Layout404,
LayoutArchive,
@@ -481,6 +534,8 @@ export {
LayoutIndex,
LayoutPostList,
LayoutSearch,
LayoutSignIn,
LayoutSignUp,
LayoutSlug,
LayoutTagIndex,
CONFIG as THEME_CONFIG