11import type { Config , ImageParameters } from "../types/config" ;
22import { hasComposer , hasNpm , hasYarn } from "./packageManagers" ;
33import { encodeUri } from "./strings" ;
4+ import type { Package } from "../types/package" ;
5+ import { detectIcon } from "./icons" ;
46
57const detectPackageManager = ( config : Config , visibility : string ) : string => {
68 if ( hasComposer ( config ) ) {
@@ -45,15 +47,19 @@ const packageName = (image: ImageParameters): string => {
4547 return image ?. packageName || "" ;
4648} ;
4749
48- const render = ( config : Config , theme : "light" | "dark" ) : string => {
50+ const render = (
51+ config : Config ,
52+ packageData : Package ,
53+ theme : "light" | "dark" ,
54+ ) : string => {
4955 const image = config . image . parameters ;
5056
5157 const params = new URLSearchParams ( {
5258 theme : theme ,
5359 pattern : image . pattern ,
5460 style : image . style ,
5561 fontSize : image . fontSize ,
56- images : image . icon ,
62+ images : image . icon || detectIcon ( packageData ) ,
5763 packageManager : packageManager ( config ) ,
5864 packageName : packageName ( image ) ,
5965 description : image . description || "" ,
@@ -66,11 +72,11 @@ const render = (config: Config, theme: "light" | "dark"): string => {
6672 ) ;
6773} ;
6874
69- export const getImages = ( config : Config ) : string => {
75+ export const getImages = ( config : Config , packageData : Package ) : string => {
7076 const title = config . image . parameters . title ;
7177
72- const light = render ( config , "light" ) ;
73- const dark = render ( config , "dark" ) ;
78+ const light = render ( config , packageData , "light" ) ;
79+ const dark = render ( config , packageData , "dark" ) ;
7480
7581 return `<picture>
7682 <source media="(prefers-color-scheme: dark)" srcset="${ dark } ">
0 commit comments