| --- | |
| import type { CollectionEntry } from 'astro:content' | |
| import type { Layout, LayoutOverridesHTMLAttributes } from '@libs/layout' | |
| import SharedBaseLayout from '@twbs/bui/components/BaseLayout' | |
| import Head from '@components/head/Head.astro' | |
| import Header from '@components/header/Header.astro' | |
| import Scripts from '@components/Scripts.astro' | |
| import Footer from '@components/footer/Footer.astro' | |
| import { getConfig } from '@libs/config' | |
| import { stripMarkdown } from '@libs/utils' | |
| type Props = { | |
| layout?: Layout | |
| overrides?: { | |
| body?: LayoutOverridesHTMLAttributes<'body'> | |
| main?: LayoutOverridesHTMLAttributes<'main'> | |
| } | |
| robots?: string | |
| title?: string | |
| } & MarkdownProps | |
| type MarkdownProps = { frontmatter?: Partial<CollectionEntry<'docs'>['data']> } | |
| const { frontmatter, layout, overrides, robots } = Astro.props | |
| const title = Astro.props.title ?? frontmatter?.title ?? getConfig().title | |
| const description = frontmatter?.description ? stripMarkdown(frontmatter.description) : getConfig().description | |
| const thumbnail = frontmatter?.thumbnail ? `img/${frontmatter.thumbnail}` : 'brand/bootstrap-social.png' | |
| const bodyProps = overrides?.body ?? {} | |
| const mainProps = overrides?.main ?? {} | |
| --- | |
| <SharedBaseLayout bodyAttrs={bodyProps} mainAttrs={mainProps}> | |
| <Head slot="head" description={description} layout={layout} robots={robots} thumbnail={thumbnail} title={title} /> | |
| <Header slot="header" layout={layout} title={title} addedIn={frontmatter?.added} /> | |
| { | |
| Astro.slots.has('main') ? ( | |
| <Fragment slot="main"> | |
| <slot name="main" /> | |
| </Fragment> | |
| ) : ( | |
| <Fragment slot="main"> | |
| <main {...{ id: 'content', ...mainProps }}> | |
| <slot /> | |
| </main> | |
| </Fragment> | |
| ) | |
| } | |
| <Footer slot="footer" /> | |
| <Fragment slot="scripts"> | |
| <Scripts layout={layout} /> | |
| {frontmatter?.extra_js && frontmatter.extra_js.map((js) => <script is:inline async={js.async} src={js.src} />)} | |
| { | |
| layout === 'docs' && ( | |
| <div class="position-fixed" aria-hidden="true"> | |
| <input type="text" tabindex="-1" /> | |
| </div> | |
| ) | |
| } | |
| </Fragment> | |
| </SharedBaseLayout> |