Skip to content

Commit 637c50e

Browse files
authored
fixing edit on remote content & adding remote files to .gitignore (#2525)
1 parent 28eacf3 commit 637c50e

File tree

8 files changed

+161
-59
lines changed

8 files changed

+161
-59
lines changed

.gitignore

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,28 +138,30 @@ package-lock.json
138138
.vercel
139139
.env*.local
140140

141+
141142
# Remote content output paths
142-
content/docs/cross-chain/avalanche-warp-messaging/deep-dive.mdx
143-
content/docs/cross-chain/avalanche-warp-messaging/run-relayer.mdx
144-
content/docs/cross-chain/teleporter/overview.mdx
145-
content/docs/cross-chain/teleporter/deep-dive.mdx
146-
content/docs/cross-chain/teleporter/cli.mdx
147-
content/docs/cross-chain/teleporter/upgradeability.mdx
148-
content/docs/cross-chain/avalanche-warp-messaging/evm-integration.mdx
149143
content/docs/api-reference/admin-api.mdx
144+
content/docs/api-reference/c-chain/api.mdx
150145
content/docs/api-reference/health-api.mdx
146+
content/docs/api-reference/index-api.mdx
151147
content/docs/api-reference/info-api.mdx
152148
content/docs/api-reference/metrics-api.mdx
153-
content/docs/api-reference/index-api.mdx
154149
content/docs/api-reference/p-chain/api.mdx
150+
content/docs/api-reference/subnet-evm-api.mdx
155151
content/docs/api-reference/x-chain/api.mdx
156-
content/docs/tooling/cli-commands.mdx
152+
content/docs/avalanche-l1s/validator-manager/contract.mdx
153+
content/docs/cross-chain/avalanche-warp-messaging/deep-dive.mdx
154+
content/docs/cross-chain/avalanche-warp-messaging/evm-integration.mdx
155+
content/docs/cross-chain/avalanche-warp-messaging/run-relayer.mdx
156+
content/docs/cross-chain/interchain-token-transfer/overview.mdx
157+
content/docs/cross-chain/teleporter/cli.mdx
158+
content/docs/cross-chain/teleporter/deep-dive.mdx
159+
content/docs/cross-chain/teleporter/overview.mdx
160+
content/docs/cross-chain/teleporter/upgradeability.mdx
161+
content/docs/nodes/chain-configs/p-chain.mdx
157162
content/docs/nodes/configure/avalanche-l1-configs.mdx
158163
content/docs/nodes/configure/chain-configs/p-chain.mdx
159164
content/docs/nodes/configure/chain-configs/x-chain.mdx
160165
content/docs/nodes/configure/configs-flags.mdx
161-
content/docs/api-reference/subnet-evm-api.mdx
162-
content/docs/avalanche-l1s/validator-manager/contract.mdx
163-
content/docs/cross-chain/interchain-token-transfer/overview.mdx
164-
content/docs/nodes/chain-configs/p-chain.mdx
165-
content/docs/api-reference/c-chain/api.mdx
166+
content/docs/tooling/cli-commands.mdx
167+

app/academy/[...slug]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export default async function Page(props: {
7878
if (!page) notFound();
7979

8080
const path = `content/academy/${page.file.path}`;
81+
const editUrl = `https://github.com/ava-labs/builders-hub/edit/master/${path}`;
8182
const MDX = page.data.body;
8283
const course = COURSES.official.find(c => c.slug === page.slugs[0]);
8384

@@ -126,6 +127,7 @@ export default async function Page(props: {
126127
path={path}
127128
title={page.data.title}
128129
pagePath={`/academy/${page.slugs.join('/')}`}
130+
editUrl={editUrl}
129131
onRateAction={async (url, feedback) => {
130132
'use server';
131133
await posthog.capture('on_rate_document', feedback);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export default async function Page(props: {
4343
const { body: MDX, toc } = await page.data.load();
4444
const path = `content/docs/${page.file.path}`;
4545

46+
// Use custom edit URL if provided in frontmatter, otherwise use default path
47+
const editUrl = page.data.edit_url || `https://github.com/ava-labs/builders-hub/edit/master/${path}`;
48+
4649
return (
4750
<DocsPage
4851
toc={toc}
@@ -92,6 +95,7 @@ export default async function Page(props: {
9295
path={path}
9396
title={page.data.title}
9497
pagePath={`/docs/${page.slugs.join('/')}`}
98+
editUrl={editUrl}
9599
onRateAction={async (url, feedback) => {
96100
'use server';
97101
await posthog.capture('on_rate_document', feedback);

app/guides/[...slug]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default async function Page(props: {
3838

3939
const MDX = page.data.body;
4040
const path = `content/guides/${page.file.path}`;
41+
const editUrl = `https://github.com/ava-labs/builders-hub/edit/master/${path}`;
4142

4243
return (
4344
<>
@@ -84,6 +85,7 @@ export default async function Page(props: {
8485
path={path}
8586
title={page.data.title}
8687
pagePath={`/guides/${page.slugs.join('/')}`}
88+
editUrl={editUrl}
8789
onRateAction={async (url, feedback) => {
8890
'use server';
8991
await posthog.capture('on_rate_document', feedback);

app/integrations/[...slug]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default async function Page(props: {
2323

2424
const { body: MDX } = await page.data.load();
2525
const path = `content/integrations/${page.file.path}`;
26+
const editUrl = `https://github.com/ava-labs/builders-hub/edit/master/${path}`;
2627

2728
return (
2829
<>
@@ -67,6 +68,7 @@ export default async function Page(props: {
6768
path={path}
6869
title={page.data.title}
6970
pagePath={`/integrations/${page.slugs.join('/')}`}
71+
editUrl={editUrl}
7072
onRateAction={async (url, feedback) => {
7173
'use server';
7274
await posthog.capture('on_rate_document', feedback);

components/ui/feedback.tsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { cva } from 'class-variance-authority';
1111
import { usePathname } from 'next/navigation';
1212
import newGithubIssueUrl from 'new-github-issue-url';
13-
13+
1414
const rateButtonVariants = cva(
1515
'inline-flex items-center gap-2 px-3 py-2 rounded-full font-medium border text-sm [&_svg]:size-4 disabled:cursor-not-allowed transition-colors hover:bg-fd-accent/80 hover:text-fd-accent-foreground',
1616
{
@@ -22,64 +22,66 @@ const rateButtonVariants = cva(
2222
},
2323
},
2424
);
25-
25+
2626
export interface Feedback {
2727
opinion: 'yes' | 'no';
2828
message: string;
2929
}
30-
30+
3131
function get(url: string): Feedback | null {
3232
const item = localStorage.getItem(`document-feedback-${url}`);
33-
33+
3434
if (item === null) return null;
3535
return JSON.parse(item) as Feedback;
3636
}
37-
37+
3838
function set(url: string, feedback: Feedback | null) {
3939
const key = `document-feedback-${url}`;
4040
if (feedback) localStorage.setItem(key, JSON.stringify(feedback));
4141
else localStorage.removeItem(key);
4242
}
43-
43+
4444
export interface UnifiedFeedbackProps {
4545
onRateAction: (url: string, feedback: Feedback) => Promise<void>;
4646
path: string;
4747
title: string;
4848
pagePath: string;
49+
editUrl: string;
4950
}
5051

5152
export function Feedback({
5253
onRateAction,
5354
path,
5455
title,
5556
pagePath,
57+
editUrl,
5658
}: UnifiedFeedbackProps) {
5759
const pathname = usePathname();
5860
const [previous, setPrevious] = useState<Feedback | null>(null);
5961
const [opinion, setOpinion] = useState<'yes' | 'no' | null>(null);
6062
const [message, setMessage] = useState('');
61-
63+
6264
useEffect(() => {
6365
setPrevious(get(pathname));
6466
}, [pathname]);
65-
67+
6668
function submit(e?: SyntheticEvent) {
6769
e?.preventDefault();
6870
if (opinion == null) return;
69-
71+
7072
const feedback: Feedback = {
7173
opinion,
7274
message,
7375
};
74-
76+
7577
void onRateAction(pathname, feedback);
76-
78+
7779
set(pathname, feedback);
7880
setPrevious(feedback);
7981
setMessage('');
8082
setOpinion(null);
8183
}
82-
84+
8385
return (
8486
<Collapsible
8587
open={opinion !== null || previous !== null}
@@ -120,17 +122,17 @@ export function Feedback({
120122
No
121123
</button>
122124
</div>
123-
125+
124126
<div className="flex flex-row items-center gap-1.5 w-full sm:w-auto">
125127
<a
126-
href={`https://github.com/ava-labs/builders-hub/edit/master/${path}`}
128+
href={editUrl}
127129
target="_blank"
128130
rel="noreferrer noopener"
129131
className={cn(rateButtonVariants(), "gap-2 no-underline text-sm")}
130132
>
131133
<PencilIcon className="size-4" /> Edit on GitHub
132134
</a>
133-
135+
134136
<a
135137
href={newGithubIssueUrl({
136138
user: 'ava-labs',
@@ -151,7 +153,7 @@ Page: [${pagePath}](https://build.avax.network${pagePath})
151153
</a>
152154
</div>
153155
</div>
154-
156+
155157
<CollapsibleContent className="mt-3">
156158
{previous ? (
157159
<div className="px-3 py-6 flex flex-col items-center gap-3 bg-fd-card text-fd-card-foreground text-sm text-center rounded-xl text-fd-muted-foreground">

source.config.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const { docs, meta } = defineDocs({
1717
async: true,
1818
schema: frontmatterSchema.extend({
1919
index: z.boolean().default(false),
20+
edit_url: z.string().optional(),
2021
}),
2122
},
2223
meta: {
@@ -33,13 +34,13 @@ export const course = defineCollections({
3334
preview: z.string().optional(),
3435
index: z.boolean().default(false),
3536
updated: z.string().or(z.date()).transform((value, context) => {
36-
try {
37-
return new Date(value);
38-
} catch {
39-
context.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid date" });
40-
return z.NEVER;
41-
}
42-
}),
37+
try {
38+
return new Date(value);
39+
} catch {
40+
context.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid date" });
41+
return z.NEVER;
42+
}
43+
}),
4344
authors: z.array(z.string()),
4445
comments: z.boolean().default(false),
4546
}),

0 commit comments

Comments
 (0)