From 18315bad4844991caadcdaafbc56550bad66d111 Mon Sep 17 00:00:00 2001 From: Sudrut Date: Sat, 13 Dec 2025 13:34:56 +0800 Subject: [PATCH 1/2] feat: add attr `section` to DocLink --- src/components/DocLink.astro | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/DocLink.astro b/src/components/DocLink.astro index a39e8551..29e316c1 100644 --- a/src/components/DocLink.astro +++ b/src/components/DocLink.astro @@ -3,13 +3,14 @@ import { getLinkToKey } from "../lib/doc-index"; interface Props { src: string; + section?: string; } -const { src } = Astro.props; +const { src, section } = Astro.props; const rawLink = await getLinkToKey(src); const missing = rawLink === undefined; -const link = rawLink ?? ""; +const link = rawLink ? rawLink + (section ? "#" + section : "") : ""; --- { From fa0f1a3e2aa00e7ae46e6343b0cb13dc98970c3a Mon Sep 17 00:00:00 2001 From: Sudrut Date: Sat, 13 Dec 2025 13:52:58 +0800 Subject: [PATCH 2/2] feat: update doc for `DocLink` --- .../guide/component-docs-for-llm.mdx | 3 ++- .../docs/development/guide/doc-everything.mdx | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/content/docs/development/guide/component-docs-for-llm.mdx b/src/content/docs/development/guide/component-docs-for-llm.mdx index dd297791..804eeb29 100644 --- a/src/content/docs/development/guide/component-docs-for-llm.mdx +++ b/src/content/docs/development/guide/component-docs-for-llm.mdx @@ -234,7 +234,8 @@ The `DocLink` component renders an inline link to a page associated with a doc k #### Props -- `src` (required): The doc key (e.g., `"cpp.library.utilities.move"`) or absolute path (e.g., `"/cpp/library/utilities/move"`). +- `src` (required): The absolute path (e.g., `"/cpp/library/utilities/move"`). +- `section` (optional): The `id` of the HTML element to jump to, typically the `id` of heading tags generated from Markdown headings. #### Slots diff --git a/src/content/docs/development/guide/doc-everything.mdx b/src/content/docs/development/guide/doc-everything.mdx index e9994bc2..dbe63e52 100644 --- a/src/content/docs/development/guide/doc-everything.mdx +++ b/src/content/docs/development/guide/doc-everything.mdx @@ -357,6 +357,26 @@ for more information about `std::move`. Check out this page for more information about `std::move`. +By setting the `section` attribute, you can link to a specific section (or any HTML elements with corresponding `id` attribute) of a CppDoc page. + +```mdx +import DocLink from "@components/DocLink.astro"; + +Standard library hardening +allows turning some instances of undefined behavior in the standard library +into a contract violation. +``` + + + Standard library hardening + allows turning some instances of undefined behavior in the standard library + into a contract violation. + +