-
Notifications
You must be signed in to change notification settings - Fork 9
Remove clean markdown generation and artifacts. #833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,14 @@ const DROPDOWN_IDENTIFIER = "Markdown for LLMs"; | |
|
|
||
| /** | ||
| * This component overrides the default nextra-theme-docs "Copy page" button behavior | ||
| * to fetch clean markdown from our API instead of copying raw MDX source. | ||
| * to fetch markdown from our API instead of copying raw MDX source. | ||
| */ | ||
| export function CopyPageOverride() { | ||
| const pathname = usePathname(); | ||
|
|
||
| const fetchAndCopyMarkdown = useCallback(async (): Promise<boolean> => { | ||
| try { | ||
| const markdownUrl = `/api/markdown${pathname}.md`; | ||
| const markdownUrl = `/api/markdown${pathname}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to add the header |
||
| const response = await fetch(markdownUrl); | ||
|
|
||
| if (!response.ok) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ function CopyPageButton() { | |
|
|
||
| setLoading(true); | ||
| try { | ||
| const response = await fetch(`/api/markdown${pathname}.md`); | ||
| const response = await fetch(`/api/markdown${pathname}`); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. won't we have to fetch with the new application/markdown header? |
||
| if (!response.ok) { | ||
| throw new Error("Failed to fetch markdown"); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,7 @@ description: "Learn how to speed up your development with agents in your IDEs" | |||||
|
|
||||||
| # Agentic Development | ||||||
|
|
||||||
| Every page on the Arcade docs site renders as clean markdown. When an AI agent or coding assistant visits any docs URL, the site automatically returns `Content-Type: text/markdown` instead of HTML if: | ||||||
| Every page on the Arcade docs site can be served as markdown. When an AI agent or coding assistant visits any docs URL, the site automatically returns `Content-Type: text/markdown` instead of HTML if: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| - The request `User-Agent` header matches a known AI agent (Claude, ChatGPT, Cursor, etc.) | ||||||
| - The request includes the `Accept: text/markdown` header | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,15 +22,16 @@ import { | |
| } from "nextra-theme-docs"; | ||
|
|
||
| const REGEX_LOCALE = /^\/([a-z]{2}(?:-[A-Z]{2})?)(?:\/|$)/; | ||
| const ENABLE_MARKDOWN_ALTERNATE = false; | ||
|
|
||
| function getMarkdownAlternatePath(pathname: string): string { | ||
| // Handle root paths | ||
| if (pathname === "/" || pathname === "") { | ||
| return "/index.md"; | ||
| return "/"; | ||
| } | ||
| // Remove trailing slash if present, then add .md extension | ||
| // Remove trailing slash if present. | ||
| const cleanPath = pathname.endsWith("/") ? pathname.slice(0, -1) : pathname; | ||
| return `${cleanPath}.md`; | ||
| return cleanPath; | ||
| } | ||
|
|
||
| export async function generateMetadata() { | ||
|
|
@@ -77,11 +78,13 @@ export async function generateMetadata() { | |
| appleWebApp: { | ||
| title: "Arcade Documentation", | ||
| }, | ||
| alternates: { | ||
| types: { | ||
| "text/markdown": getMarkdownAlternatePath(pathname), | ||
| }, | ||
| }, | ||
| alternates: ENABLE_MARKDOWN_ALTERNATE | ||
| ? { | ||
| types: { | ||
| "text/markdown": getMarkdownAlternatePath(pathname), | ||
| }, | ||
| } | ||
| : undefined, | ||
|
Comment on lines
+81
to
+87
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we were removing all of this from our code and having cloudflare do it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeh, tomorrow I have to take a better look on this, there are more things then I expected related to the MD files. |
||
| other: { | ||
| "apple-mobile-web-app-title": "Arcade Documentation", | ||
| "twitter:url": "https://docs.arcade.dev", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,15 +101,15 @@ function getLocaleFromPathname(pathname: string, request: NextRequest): string { | |
|
|
||
| function buildMarkdownPath(pathname: string, locale: string): string { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this function is no longer needed |
||
| if (pathname === "/" || pathname === "") { | ||
| return `/${locale}/home.md`; | ||
| return `/${locale}/home`; | ||
| } | ||
| if (pathnameIsMissingLocale(pathname)) { | ||
| return `/${locale}${pathname}.md`; | ||
| return `/${locale}${pathname}`; | ||
| } | ||
| if (SUPPORTED_LOCALES.some((loc) => pathname === `/${loc}`)) { | ||
| return `${pathname}/home.md`; | ||
| return `${pathname}/home`; | ||
| } | ||
| return `${pathname}.md`; | ||
| return pathname; | ||
| } | ||
|
|
||
| function isToolkitDetailPath(pathname: string): boolean { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure we want to keep most of this - it only regenerates the summary for changed pages. It's very slow/expensive to do them all