Skip to content

Commit

Permalink
Fix type errors during build phase
Browse files Browse the repository at this point in the history
  • Loading branch information
pengqun committed Jan 27, 2024
1 parent d83813d commit e6e45e4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"lint:eslint": "eslint . --ext .js,.ts,.astro"
},
"dependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/rss": "^4.0.2",
"@astrojs/sitemap": "^3.0.5",
"@astrolib/analytics": "^0.5.0",
Expand All @@ -21,10 +22,9 @@
"astro-icon": "^1.0.2",
"limax": "4.1.0",
"lodash.merge": "^4.6.2",
"typescript": "^5.3.3",
"typescript-esbuild": "^0.3.6",
"unpic": "^3.16.0",
"@astrojs/check": "^0.4.1",
"typescript": "^5.3.3"
"unpic": "^3.16.0"
},
"devDependencies": {
"@astrojs/mdx": "^2.0.5",
Expand All @@ -33,6 +33,7 @@
"@iconify-json/flat-color-icons": "^1.1.10",
"@iconify-json/tabler": "^1.1.104",
"@tailwindcss/typography": "^0.5.10",
"@types/js-yaml": "^4.0.9",
"@types/lodash.merge": "^4.6.9",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
Expand All @@ -51,4 +52,4 @@
"engines": {
"node": ">=18.14.1"
}
}
}
15 changes: 13 additions & 2 deletions src/utils/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,22 @@ export const adaptOpenGraphImages = async (
height: image?.height || defaultHeight,
});

interface ImageWithDimensions {
width?: number;
height?: number;
}

if (typeof _image === 'object') {
return {
url: typeof _image.src === 'string' ? String(new URL(_image.src, astroSite)) : 'pepe',
width: typeof _image.width === 'number' ? _image.width : undefined,
height: typeof _image.height === 'number' ? _image.height : undefined,
width:
typeof (_image as ImageWithDimensions).width === 'number'
? (_image as ImageWithDimensions).width
: undefined,
height:
typeof (_image as ImageWithDimensions).height === 'number'
? (_image as ImageWithDimensions).height
: undefined,
};
}
return {
Expand Down

0 comments on commit e6e45e4

Please sign in to comment.