Skip to content

Commit d52477e

Browse files
committed
chore: add conditional checks for titleCard to prevent undefined values
1 parent e009086 commit d52477e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/card.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,18 @@ async function card(data: GetData, uiConfig: UiConfig): Promise<string> {
3838
const isRtlDirection = parseBoolean(selectLocale.rtlDirection);
3939
const isDisabledAnimations = parseBoolean(uiConfig.disabledAnimations || uiConfig.Format === "png");
4040

41-
const customTitleCard = uiConfig.Title || selectLocale.titleCard;
41+
let titleCard = defaultLocale.titleCard.split("{name}").join(data.name);
42+
if (uiConfig.Title ||
43+
uiConfig.Title.length ||
44+
uiConfig.Title !== "undefined" ||
45+
uiConfig.Title !== "") {
46+
titleCard = uiConfig.Title.split("{name}").join(data.name);
47+
} else if (selectLocale.titleCard ||
48+
selectLocale.titleCard.length ||
49+
selectLocale.titleCard !== "undefined" ||
50+
selectLocale.titleCard !== "") {
51+
titleCard = selectLocale.titleCard.split("{name}").join(data.name);
52+
}
4253

4354
const direction = isRtlDirection ? "rtl" : "ltr";
4455
const angle = {
@@ -217,11 +228,11 @@ async function card(data: GetData, uiConfig: UiConfig): Promise<string> {
217228
display: block;
218229
}
219230
</style>
220-
<title id="titleId">${customTitleCard.split("{name}").join(data.name) || defaultLocale.titleCard.split("{name}").join(data.name)}</title>
231+
<title id="titleId">${titleCard}</title>
221232
${backgroundSVG}
222233
<g transform="translate(0, 25)">
223234
<g class="div-animation">
224-
<text x="${angle.titleXAngle}" y="${angle.titleYAngle}" class="text-title">${customTitleCard.split("{name}").join(data.name) || defaultLocale.titleCard.split("{name}").join(data.name)}</text>
235+
<text x="${angle.titleXAngle}" y="${angle.titleYAngle}" class="text-title">${titleCard}</text>
225236
</g>
226237
<g class="image-profile-animation">
227238
<defs>

0 commit comments

Comments
 (0)