mirror of
https://github.com/twbs/bootstrap.git
synced 2025-07-04 00:01:57 -04:00
Compare commits
2 Commits
240b3bffb3
...
1fb48815af
Author | SHA1 | Date | |
---|---|---|---|
|
1fb48815af | ||
|
1fa6372aec |
@ -33,9 +33,14 @@ interface Props {
|
|||||||
* This takes precedence over the `code` prop.
|
* This takes precedence over the `code` prop.
|
||||||
*/
|
*/
|
||||||
filePath?: string
|
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
|
let codeToDisplay = filePath
|
||||||
? fs.readFileSync(path.join(process.cwd(), filePath), 'utf8')
|
? fs.readFileSync(path.join(process.cwd(), filePath), 'utf8')
|
||||||
@ -130,11 +135,15 @@ if (filePath && fileMatch && codeToDisplay) {
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class:list={['bd-code-snippet', containerClass]}>
|
<div class:list={[{ 'bd-code-snippet': !nested }, containerClass]}>
|
||||||
{
|
{
|
||||||
Astro.slots.has('pre') ? (
|
nested
|
||||||
|
? (<></>)
|
||||||
|
: Astro.slots.has('pre')
|
||||||
|
? (
|
||||||
<slot name="pre" />
|
<slot name="pre" />
|
||||||
) : (
|
)
|
||||||
|
: (
|
||||||
<div class="bd-clipboard">
|
<div class="bd-clipboard">
|
||||||
<button type="button" class="btn-clipboard">
|
<button type="button" class="btn-clipboard">
|
||||||
<svg class="bi" role="img" aria-label="Copy">
|
<svg class="bi" role="img" aria-label="Copy">
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { replacePlaceholdersInHtml } from '@libs/placeholder'
|
import { replacePlaceholdersInHtml } from '@libs/placeholder'
|
||||||
import { Prism } from '@astrojs/prism'
|
import Code from '@components/shortcodes/Code.astro'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
/**
|
/**
|
||||||
@ -96,9 +96,7 @@ const simplifiedMarkup = markup
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div class="highlight">
|
<Code code={simplifiedMarkup} lang={lang} nested={true} />
|
||||||
<Prism code={simplifiedMarkup} lang={lang} />
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user