Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(kumascript): make smartLink()'s content parameter optional #9847

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions kumascript/src/api/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const web = {
// then hyperlink to corresponding en-US document is returned.
smartLink(
this: KumaThis,
href,
title,
content,
subpath,
basepath,
ignoreFlawMacro = null
href: string,
title: string | null,
content: string | null = null,
subpath: string | null = null,
basepath: string | null = null,
ignoreFlawMacro: string | null = null
) {
let flaw;
let flawAttribute = "";
Expand Down Expand Up @@ -128,6 +128,7 @@ const web = {
}
}
const titleAttribute = title ? ` title="${title}"` : "";
content ??= page.short_title ?? page.title;
return `<a href="${
page.url + hrefhash
}"${titleAttribute}${flawAttribute}>${content}</a>`;
Expand All @@ -150,6 +151,7 @@ const web = {
flaw.macroSource
)}"`;
}
content ??= enUSPage.short_title ?? enUSPage.title;
return (
'<a class="only-in-en-us" ' +
'title="Currently only available in English (US)" ' +
Expand All @@ -171,6 +173,7 @@ const web = {
this.web.getJSONData("L10n-Common"),
"summary"
);
content ??= href;
return `<a class="page-not-created" title="${titleWhenMissing}"${flawAttribute}>${content}</a>`;
},

Expand Down
Loading