Skip to content

Commit cd922a1

Browse files
authored
release v3.1.0 (#1049)
1 parent e5c9669 commit cd922a1

File tree

31 files changed

+998
-108
lines changed

31 files changed

+998
-108
lines changed

.env-example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
NEXT_PUBLIC_GTM_ID=
22
LLMS_BASE_URL=
3+
GITHUB_APP_ID=
4+
GITHUB_APP_PRIVATE_KEY= # Base64 encoded GitHub App private key
5+
GITHUB_APP_INSTALLATION_ID=
6+
GITHUB_DISCUSSION_CATEGORY_ID=
7+
GITHUB_REPOSITORY=

app/(docs)/[...slug]/page.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { Mermaid } from "@/components/mdx/mermaid";
3131
import { Callout } from "@/components/callout";
3232
import * as customIcons from "@/components/ui/icon";
3333
import * as lucideIcons from "lucide-react";
34+
import { FeedbackWrapper } from "@/components/feedback/feedback-wrapper";
3435

3536
export default async function Page(props: {
3637
params: Promise<{ slug?: string[] }>;
@@ -163,7 +164,7 @@ export default async function Page(props: {
163164
/>
164165
),
165166
input: (
166-
props: React.InputHTMLAttributes<HTMLInputElement>
167+
props: React.InputHTMLAttributes<HTMLInputElement>,
167168
) => {
168169
if (props.type === "checkbox") {
169170
return (
@@ -189,6 +190,11 @@ export default async function Page(props: {
189190
})}
190191
/>
191192
</DocsPageProse>
193+
<div className="border-b border-border/50" />
194+
<FeedbackWrapper
195+
pageTitle={page.data.title}
196+
pagePath={page.url}
197+
/>
192198
</DocsPageContent>
193199
</DocsPageContentWrapper>
194200
</DocsPageLayout>
@@ -261,7 +267,7 @@ export default async function Page(props: {
261267
/>
262268
),
263269
input: (
264-
props: React.InputHTMLAttributes<HTMLInputElement>
270+
props: React.InputHTMLAttributes<HTMLInputElement>,
265271
) => {
266272
if (props.type === "checkbox") {
267273
return (
@@ -287,6 +293,11 @@ export default async function Page(props: {
287293
})}
288294
/>
289295
</DocsPageProse>
296+
<div className="border-b border-border/50" />
297+
<FeedbackWrapper
298+
pageTitle={page.data.title}
299+
pagePath={page.url}
300+
/>
290301
</DocsPageContent>
291302
</DocsPageContentWrapper>
292303
</DocsPageLayout>
@@ -299,7 +310,7 @@ export async function generateStaticParams() {
299310
return source.generateParams().filter(
300311
(params) =>
301312
// Filter out empty slug arrays (root path)
302-
params.slug && params.slug.length > 0
313+
params.slug && params.slug.length > 0,
303314
);
304315
}
305316

app/api/feedback/route.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { NextRequest, NextResponse } from 'next/server';
2+
import {
3+
findDiscussionByTitle,
4+
createDiscussion,
5+
addDiscussionComment,
6+
formatDiscussionTitle,
7+
formatDiscussionBody,
8+
} from '@/lib/github-discussions';
9+
10+
export const runtime = 'nodejs';
11+
12+
interface FeedbackRequest {
13+
pageTitle: string;
14+
pagePath: string;
15+
pageUrl: string;
16+
helpful: boolean;
17+
feedback?: string;
18+
}
19+
20+
export async function POST(request: NextRequest) {
21+
try {
22+
const body: FeedbackRequest = await request.json();
23+
const { pageTitle, pagePath, pageUrl, helpful, feedback } = body;
24+
25+
if (!pageTitle || !pagePath || !pageUrl || helpful === undefined) {
26+
return NextResponse.json(
27+
{ error: 'Missing required fields' },
28+
{ status: 400 }
29+
);
30+
}
31+
32+
const discussionTitle = formatDiscussionTitle(pageTitle, pagePath);
33+
34+
let discussion = await findDiscussionByTitle(discussionTitle);
35+
36+
if (!discussion) {
37+
const discussionBody = formatDiscussionBody(pageTitle, pageUrl);
38+
discussion = await createDiscussion(discussionTitle, discussionBody);
39+
}
40+
41+
const emoji = helpful ? '👍' : '👎';
42+
const commentBody = feedback
43+
? `**Feedback**: ${emoji}\n\n${feedback}`
44+
: `**Feedback**: ${emoji}`;
45+
46+
await addDiscussionComment(discussion.id, commentBody);
47+
48+
return NextResponse.json({
49+
success: true,
50+
discussionUrl: discussion.url,
51+
discussionNumber: discussion.number,
52+
});
53+
54+
} catch (error) {
55+
console.error('Error handling feedback:', error);
56+
return NextResponse.json(
57+
{ error: 'Failed to submit feedback' },
58+
{ status: 500 }
59+
);
60+
}
61+
}

bun.lock

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)