From 1fa6372aec0a6c0c8b433296dd5406d7dcd543a4 Mon Sep 17 00:00:00 2001 From: Louis-Maxime Piton Date: Tue, 1 Jul 2025 12:09:48 +0200 Subject: [PATCH] fix(docs): Add a tooltip on buttons whenever `` is called and not only `` --- site/src/components/shortcodes/Code.astro | 39 ++++++++++++-------- site/src/components/shortcodes/Example.astro | 6 +-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/site/src/components/shortcodes/Code.astro b/site/src/components/shortcodes/Code.astro index 231002a50b..53d170859b 100644 --- a/site/src/components/shortcodes/Code.astro +++ b/site/src/components/shortcodes/Code.astro @@ -33,15 +33,20 @@ interface Props { * This takes precedence over the `code` prop. */ filePath?: string + /** + * If the component is nested inside an example or not. + * @default false + */ + nested?: boolean } -const { class: className, code, containerClass, fileMatch, filePath, lang } = Astro.props +const { class: className, code, containerClass, fileMatch, filePath, lang, nested = false } = Astro.props let codeToDisplay = filePath ? fs.readFileSync(path.join(process.cwd(), filePath), 'utf8') : Array.isArray(code) - ? code.join('\n') - : code + ? code.join('\n') + : code if (filePath && fileMatch && codeToDisplay) { const match = codeToDisplay.match(new RegExp(fileMatch)) @@ -130,19 +135,23 @@ if (filePath && fileMatch && codeToDisplay) { }) -
+
{ - Astro.slots.has('pre') ? ( - - ) : ( -
- -
- ) + nested + ? (<>) + : Astro.slots.has('pre') + ? ( + + ) + : ( +
+ +
+ ) }
{ diff --git a/site/src/components/shortcodes/Example.astro b/site/src/components/shortcodes/Example.astro index a09fffeb31..767f4cf497 100644 --- a/site/src/components/shortcodes/Example.astro +++ b/site/src/components/shortcodes/Example.astro @@ -1,6 +1,6 @@ --- import { replacePlaceholdersInHtml } from '@libs/placeholder' -import { Prism } from '@astrojs/prism' +import Code from '@components/shortcodes/Code.astro' interface Props { /** @@ -96,9 +96,7 @@ const simplifiedMarkup = markup
)} -
- -
+ ) } -- 2.39.5