make image_preview optional

This commit is contained in:
Bikrant Jajware
2023-11-02 10:51:15 +05:30
parent 5bfccb0faf
commit d4b16d2935
4 changed files with 8 additions and 1 deletions
+2
View File
@@ -24,6 +24,7 @@ export default async (req, res) => {
locale,
border_radius,
border_color,
show_image,
} = req.query;
res.setHeader("Content-Type", "image/svg+xml");
@@ -80,6 +81,7 @@ export default async (req, res) => {
border_color,
show_owner: parseBoolean(show_owner),
locale: locale ? locale.toLowerCase() : null,
show_image: parseBoolean(show_image),
}),
);
} catch (err) {
+2 -1
View File
@@ -74,6 +74,7 @@ const renderRepoCard = (repo, options = {}) => {
border_radius,
border_color,
locale,
show_image = false,
} = options;
const lineHeight = 10;
@@ -142,7 +143,7 @@ const renderRepoCard = (repo, options = {}) => {
height,
border_radius,
colors,
imageUrl: openGraphImageUrl,
imageUrl: show_image ? openGraphImageUrl : "",
});
card.disableAnimations();
+1
View File
@@ -32,6 +32,7 @@ export type StatCardOptions = CommonOptions & {
export type RepoCardOptions = CommonOptions & {
show_owner: boolean;
show_image: boolean;
};
export type TopLangOptions = CommonOptions & {
+3
View File
@@ -209,6 +209,9 @@ class Card {
`;
};
/**
* @returns {string} Renders social preview image
*/
renderImage = () => {
if (!this.imageUrl) {
return "";