@@ -585,18 +585,18 @@ function supports_svelte_versions(version_range: string): {
585
585
return result ;
586
586
}
587
587
588
- function dont_end_by ( str : string , not_all_allowed : string [ ] ) : string {
589
- for ( const nope of not_all_allowed ) {
590
- if ( str . endsWith ( nope ) ) {
591
- return str . slice ( 0 , - nope . length ) ;
588
+ function remove_ending_by ( str : string , endings : string [ ] ) : string {
589
+ for ( const ending of endings ) {
590
+ if ( str . endsWith ( ending ) ) {
591
+ return str . slice ( 0 , - ending . length ) ;
592
592
}
593
593
}
594
594
return str ;
595
595
}
596
596
597
597
function calculate_description ( pkg : PackageKey & PackageNpm ) : string {
598
598
const found = FEATURED . flatMap ( ( f ) => f . packages ) . find ( ( p ) => p . name === pkg . name ) ;
599
- if ( found && found . description ) return dont_end_by ( found . description , [ '.' ] ) ;
599
+ if ( found && found . description ) return remove_ending_by ( found . description , [ '.' ] ) ;
600
600
601
601
let desc = pkg . npm_description ?? 'NO DESCRIPTION!' ;
602
602
const replaces = [
@@ -606,14 +606,20 @@ function calculate_description(pkg: PackageKey & PackageNpm): string {
606
606
for ( const { key, value } of replaces ) {
607
607
desc = desc . replace ( key , value ) ;
608
608
}
609
- return dont_end_by ( desc , [ '.' ] ) ;
609
+ return remove_ending_by ( desc , [ '.' ] ) ;
610
+ }
611
+
612
+ function calculate_homepage ( pkg : PackageKey & PackageNpm ) : string {
613
+ return remove_ending_by ( pkg . homepage ?? '' , [ '#readme' ] ) ;
610
614
}
611
615
612
616
export const PACKAGES_META = {
613
617
FEATURED ,
614
618
619
+ calculate_description,
620
+ calculate_homepage,
621
+
615
622
is_official,
616
623
is_outdated,
617
- supports_svelte_versions,
618
- calculate_description
624
+ supports_svelte_versions
619
625
} ;
0 commit comments