Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/[[...path]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ApiPage} from 'sentry-docs/components/apiPage';
import {DocPage} from 'sentry-docs/components/docPage';
import {Home} from 'sentry-docs/components/home';
import {Include} from 'sentry-docs/components/include';
import {markdownExportUrl} from 'sentry-docs/components/markdownExportNotice';
import {PageLoadMetrics} from 'sentry-docs/components/pageLoadMetrics';
import {PlatformContent} from 'sentry-docs/components/platformContent';
import {SpecChangelog} from 'sentry-docs/components/specChangelog';
Expand Down Expand Up @@ -413,6 +414,9 @@ export async function generateMetadata(props: MetadataProps): Promise<Metadata>
},
alternates: {
canonical,
types: {
'text/markdown': markdownExportUrl(params.path?.join('/') ?? ''),
},
},
robots: noindex ? 'noindex' : undefined,
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/docPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {DocFeedback} from '../docFeedback';
import {FeatureBadge} from '../featureBadge';
import {GitHubCTA} from '../githubCTA';
import {Header} from '../header';
import {MarkdownExportNotice} from '../markdownExportNotice';
import Mermaid from '../mermaid';
import {PaginationNav} from '../paginationNav';
import {PlatformSdkDetail} from '../platformSdkDetail';
Expand Down Expand Up @@ -122,6 +123,7 @@ export async function DocPage({
</h1>
<h2>{frontMatter.description}</h2>
</hgroup>
<MarkdownExportNotice pathname={pathname} />
{/* This exact id is important for Algolia indexing */}
<div id="main">
{frontMatter.runtime && <RuntimeSelector />}
Expand Down
38 changes: 38 additions & 0 deletions src/components/markdownExportNotice.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {DOCS_ORIGIN} from 'sentry-docs/docsSite.mjs';

type Props = {
pathname: string;
};

/**
* Returns the URL of a page's Markdown export, for example
* `platforms/javascript` → `https://docs.sentry.io/platforms/javascript.md`.
*/
export function markdownExportUrl(pathname: string): string {
return `${DOCS_ORIGIN}/${pathname || 'index'}.md`;
}

/** Drops the protocol so screen readers don't read out "https://" on every page. */
function displayUrl(url: string): string {
return url.replace(/^https?:\/\//, '');
}

/**
* Plain-text pointer to the page's Markdown export and llms.txt, server-rendered near
* the top of the page so it survives HTML stripping and truncation by AI agents.
* The visible URLs stay resolvable after an agent strips the `href`s.
*
* DocPage renders this outside `div#main`, which keeps it out of the generated
* Markdown exports and the Algolia index.
*/
export function MarkdownExportNotice({pathname}: Props) {
const mdUrl = markdownExportUrl(pathname);
const llmsUrl = `${DOCS_ORIGIN}/llms.txt`;

return (
<p className="text-sm text-[var(--gray-11)] mt-0 mb-6">
Markdown version: <a href={mdUrl}>{displayUrl(mdUrl)}</a>. Index of all pages:{' '}
<a href={llmsUrl}>{displayUrl(llmsUrl)}</a>.
</p>
);
}
Loading