Skip to content

Commit c7e9cb5

Browse files
committed
add github discussion url field for post
1 parent dfd0c45 commit c7e9cb5

File tree

8 files changed

+39
-5
lines changed

8 files changed

+39
-5
lines changed

src/app/(frontend)/fonts/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import localFont from 'next/font/local'
22

3-
export const logo = localFont({
3+
export const LogoFont = localFont({
44
src: [
55
{
66
path: './Press-Start-2P-Regular.ttf',

src/app/(frontend)/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import { draftMode } from 'next/headers'
1515

1616
import './globals.css'
1717
import { getServerSideURL } from '@/utilities/getURL'
18-
import { logo } from './fonts'
18+
import { LogoFont } from './fonts'
1919

2020
export default async function RootLayout({ children }: { children: React.ReactNode }) {
2121
const { isEnabled } = await draftMode()
2222

2323
return (
2424
<html
25-
className={cn(GeistSans.variable, GeistMono.variable, logo.variable)}
25+
className={cn(GeistSans.variable, GeistMono.variable, LogoFont.variable)}
2626
lang="en"
2727
suppressHydrationWarning
2828
>

src/app/(frontend)/posts/[slug]/page.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default async function Post({ params: paramsPromise }: Args) {
4848
const decodedSlug = decodeURIComponent(slug)
4949
const url = '/posts/' + decodedSlug
5050
const post = await queryPostBySlug({ slug: decodedSlug })
51+
console.log('👉👉post👈👈-51', post)
5152

5253
if (!post) return <PayloadRedirects url={url} />
5354

@@ -72,6 +73,19 @@ export default async function Post({ params: paramsPromise }: Args) {
7273
/>
7374
)}
7475
</div>
76+
77+
{post.githubDiscussionUrl && (
78+
<div className="mt-12 border-t pt-6 text-sm">
79+
<a
80+
href={post.githubDiscussionUrl}
81+
target="_blank"
82+
rel="noopener noreferrer"
83+
className="hover:underline"
84+
>
85+
💬 在 GitHub 参与评论
86+
</a>
87+
</div>
88+
)}
7589
</div>
7690
</article>
7791
)

src/collections/Posts/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ export const Posts: CollectionConfig<'posts'> = {
217217
],
218218
},
219219
slugField(),
220+
{
221+
name: 'githubDiscussionUrl',
222+
type: 'text',
223+
label: 'GitHub 评论地址',
224+
admin: {
225+
position: 'sidebar',
226+
},
227+
},
220228
],
221229
hooks: {
222230
afterChange: [revalidatePost],

src/components/BeforeDashboard/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Banner } from '@payloadcms/ui/elements/Banner'
22
import React from 'react'
3-
3+
import { SeedButton } from './SeedButton'
44
import './index.scss'
55

66
const baseClass = 'before-dashboard'
@@ -22,6 +22,7 @@ const BeforeDashboard: React.FC = () => {
2222
Visit payload docs
2323
</a>
2424
</div>
25+
{/* <SeedButton /> */}
2526
</div>
2627
)
2728
}

src/migrations/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as migration_20260106_184630 from './20260106_184630';
22
import * as migration_20260107_045216 from './20260107_045216';
33
import * as migration_20260111_154244 from './20260111_154244';
4+
import * as migration_20260115_113014 from './20260115_113014';
45

56
export const migrations = [
67
{
@@ -16,6 +17,11 @@ export const migrations = [
1617
{
1718
up: migration_20260111_154244.up,
1819
down: migration_20260111_154244.down,
19-
name: '20260111_154244'
20+
name: '20260111_154244',
21+
},
22+
{
23+
up: migration_20260115_113014.up,
24+
down: migration_20260115_113014.down,
25+
name: '20260115_113014'
2026
},
2127
];

src/payload-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ export interface Post {
275275
*/
276276
generateSlug?: boolean | null;
277277
slug: string;
278+
githubDiscussionUrl?: string | null;
278279
updatedAt: string;
279280
createdAt: string;
280281
_status?: ('draft' | 'published') | null;
@@ -1349,6 +1350,7 @@ export interface PostsSelect<T extends boolean = true> {
13491350
};
13501351
generateSlug?: T;
13511352
slug?: T;
1353+
githubDiscussionUrl?: T;
13521354
updatedAt?: T;
13531355
createdAt?: T;
13541356
_status?: T;

src/views/System/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ const System = async ({ initPageResult, params, searchParams }: AdminViewServerP
2525
>
2626
<Gutter>
2727
<Backup />
28+
<Gutter>
29+
<a href="/admin">返回 Admin 主页</a>
30+
</Gutter>
2831
</Gutter>
2932
</DefaultTemplate>
3033
)

0 commit comments

Comments
 (0)