web/user: revert truncate behaviour for application description

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-02-15 11:16:14 +01:00
parent d945d30cda
commit ade397fc24
No known key found for this signature in database
2 changed files with 16 additions and 2 deletions

View File

@ -29,6 +29,20 @@ export function convertToTitle(text: string): string {
}); });
} }
/**
* Truncate a string based on maximum word count
*/
export function truncateWords(string: string, length = 10): string {
string = string || "";
const array = string.trim().split(" ");
const ellipsis = array.length > length ? "..." : "";
return array.slice(0, length).join(" ") + ellipsis;
}
/**
* Truncate a string based on character count
*/
export function truncate(string: string, length = 10): string { export function truncate(string: string, length = 10): string {
return string.length > length ? `${string.substring(0, length)}...` : string; return string.length > length ? `${string.substring(0, length)}...` : string;
} }

View File

@ -1,6 +1,6 @@
import { uiConfig } from "@goauthentik/common/ui/config"; import { uiConfig } from "@goauthentik/common/ui/config";
import { me } from "@goauthentik/common/users"; import { me } from "@goauthentik/common/users";
import { truncate } from "@goauthentik/common/utils"; import { truncateWords } from "@goauthentik/common/utils";
import { AKElement } from "@goauthentik/elements/Base"; import { AKElement } from "@goauthentik/elements/Base";
import { t } from "@lingui/macro"; import { t } from "@lingui/macro";
@ -127,7 +127,7 @@ export class LibraryApplication extends AKElement {
</div> </div>
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
${truncate(this.application.metaDescription || "", 35)} ${truncateWords(this.application.metaDescription || "", 35)}
</div> </div>
</div>`; </div>`;
} }