@@ -40,6 +40,12 @@ const TEST_FRAMEWORKS = [
4040 "zora"
4141] ;
4242
43+ function composeBadgeUrl ( base : string ) : string {
44+ const url = new URL ( base ) ;
45+ url . searchParams . set ( "style" , "flat-square" ) ;
46+ return url . href ;
47+ }
48+
4349export function useRepository ( data : Ref < Repository > ) {
4450 const hostingName = computed < string | null > ( ( ) => {
4551 if ( ! data . value . homepage ) return null ;
@@ -51,18 +57,24 @@ export function useRepository(data: Ref<Repository>) {
5157 return null ;
5258 }
5359 } ) ;
54- const uptimerobotBadge = computed < string | null > ( ( ) => {
55- if ( ! data . value . integrations ?. uptimerobotKey ) return null ;
56- return `https://img.shields.io/uptimerobot/ratio/${ data . value . integrations . uptimerobotKey } ` ;
60+ const uptimeRobotBadge = computed < string | null > ( ( ) => {
61+ const key = data . value . integrations ?. uptimerobotKey ;
62+ if ( ! key ) return null ;
63+ return composeBadgeUrl ( `https://img.shields.io/uptimerobot/ratio/${ key } ` ) ;
5764 } ) ;
5865 const hostingStatusBadge = computed < string | null > ( ( ) => {
59- if ( ! data . value . integrations ?. hostingProjectId ) return null ;
60- if ( hostingName . value ?. includes ( "netlify" ) ) {
61- return `https://api.netlify.com/api/v1/badges/${ data . value . integrations . hostingProjectId } /deploy-status` ;
62- }
66+ const projectId = data . value . integrations ?. hostingProjectId ;
67+ if ( ! projectId ) return null ;
68+ if ( hostingName . value ?. includes ( "netlify" ) ) return composeBadgeUrl ( `https://img.shields.io/netlify/${ projectId } ` ) ;
6369 return null ;
6470 } ) ;
65- const workflowBadge = computed < string | null > ( ( ) => data . value . integrations . workflowBadge ?? null ) ;
71+ const workflowBadge = computed < string | null > ( ( ) => {
72+ const { integrations, owner, name } = data . value ;
73+ if ( ! integrations . workflowBadge ) return null ;
74+ return composeBadgeUrl (
75+ `https://img.shields.io/github/actions/workflow/status/${ owner . login } /${ name } /${ integrations . workflowBadge } `
76+ ) ;
77+ } ) ;
6678 const packageManager = computed < string | null > ( ( ) => data . value . integrations . packageManager ?? null ) ;
6779 const license = computed < string | null > ( ( ) => {
6880 if ( ! data . value . license ) return null ;
@@ -71,7 +83,7 @@ export function useRepository(data: Ref<Repository>) {
7183 } ) ;
7284
7385 const hasBadges = computed < boolean > ( ( ) => {
74- return ! ! hostingStatusBadge . value || ! ! uptimerobotBadge . value || ! ! workflowBadge . value ;
86+ return ! ! hostingStatusBadge . value || ! ! uptimeRobotBadge . value || ! ! workflowBadge . value ;
7587 } ) ;
7688
7789 const bundler = computed < string [ ] > ( ( ) => {
@@ -85,7 +97,7 @@ export function useRepository(data: Ref<Repository>) {
8597
8698 return {
8799 hostingName,
88- uptimerobotBadge ,
100+ uptimeRobotBadge ,
89101 hostingStatusBadge,
90102 workflowBadge,
91103 packageManager,
0 commit comments