mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-16 10:34:07 +02:00
Bump image-size
from 1.0.2 to 2.0.2 (#41384)
This commit is contained in:
@@ -14,7 +14,7 @@ interface Props {
|
||||
const { description, layout, thumbnail, title } = Astro.props
|
||||
|
||||
const socialImageUrl = new URL(getVersionedDocsPath(`assets/${thumbnail}`), Astro.site)
|
||||
const socialImageSize = getStaticImageSize(`/docs/[version]/assets/${thumbnail}`)
|
||||
const socialImageSize = await getStaticImageSize(`/docs/[version]/assets/${thumbnail}`)
|
||||
---
|
||||
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
|
@@ -1,11 +1,14 @@
|
||||
import path from 'node:path'
|
||||
import { promises as fs } from 'node:fs'
|
||||
import sizeOf from 'image-size'
|
||||
import { getDocsStaticFsPath } from './path'
|
||||
|
||||
export function getStaticImageSize(imagePath: string) {
|
||||
const size = sizeOf(path.join(getDocsStaticFsPath(), imagePath))
|
||||
export async function getStaticImageSize(imagePath: string) {
|
||||
const fullPath = path.join(getDocsStaticFsPath(), imagePath)
|
||||
const buffer = await fs.readFile(fullPath)
|
||||
const size = await sizeOf(buffer)
|
||||
|
||||
if (!size.height || !size.width) {
|
||||
if (!size?.height || !size?.width) {
|
||||
throw new Error(`Failed to get size of static image at '${imagePath}'.`)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user