
| Current Path : /var/www/html/konvbav/vendor/twbs/bootstrap/site/src/layouts/partials/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/konvbav/vendor/twbs/bootstrap/site/src/layouts/partials/ResponsiveImage.astro |
---
// TODO: This Astro component could be improved to implement the equivalent of Hugo's `imageConfig`
// and calculate the width and height of the image automatically
import { getVersionedDocsPath } from '@libs/path'
interface Props {
imgPath: string
alt: string
classes?: string
lazyload?: boolean
width?: number
height?: number
}
const { imgPath, alt, classes = '', lazyload = true, width, height } = Astro.props
const classNames = ['img-fluid', 'mx-auto', classes].filter(Boolean).join(' ')
const basePath = getVersionedDocsPath(imgPath.split('/').slice(0, -1).join('/'))
const basename = imgPath.split('/').pop()?.split('.')[0] || ''
const ext = imgPath.includes('.') ? `.${imgPath.split('.').pop()}` : ''
const imgPath1x = `${basePath}/${basename}${ext}`
const imgPath2x = `${basePath}/${basename}@2x${ext}`
---
<img
class={classNames}
srcset={`${imgPath1x}, ${imgPath2x} 2x`}
src={imgPath1x}
alt={alt}
loading={lazyload ? 'lazy' : undefined}
width={width}
height={height}
/>