@@ -50,7 +50,7 @@ const readSiteModel = (inputDirectory, config) => {
5050 const packageManifestPath = safeResolve ( inputDirectory , packageEntry . manifest )
5151 const packageDirectory = dirname ( packageManifestPath )
5252 const packageManifest = readJson ( packageManifestPath )
53- if ( packageManifest . schemaVersion !== 3 || ! Array . isArray ( packageManifest . modules ) ) {
53+ if ( packageManifest . schemaVersion !== 4 || ! Array . isArray ( packageManifest . modules ) ) {
5454 throw new Error ( "Unsupported API reference package manifest" )
5555 }
5656
@@ -294,7 +294,9 @@ export const renderLayout = (site, { content, currentRoute, description, pageKin
294294`
295295}
296296
297- const renderHeader = ( site ) => `
297+ const renderHeader = ( site ) => {
298+ const repository = githubRepository ( site . package . repositoryUrl )
299+ return `
298300 <a class="skip-link" href="#main-content">Skip to content</a>
299301 <header class="site-header" data-pagefind-ignore>
300302 <div class="site-header__brand">
@@ -310,10 +312,26 @@ const renderHeader = (site) => `
310312 <span>Search the API</span>
311313 <kbd>⌘ K</kbd>
312314 </button>
313- <a class="header-link" href="${ escapeAttribute ( site . package . sourceUrl ) } ">GitHub</a>
315+ <a class="header-link github-link" href="${ escapeAttribute ( site . package . repositoryUrl ) } " aria-label="View ${ escapeAttribute ( repository ) } on GitHub">
316+ <span class="github-link__label">GitHub</span>
317+ <span class="github-stars" data-github-stars="${ escapeAttribute ( repository ) } " hidden>
318+ <svg aria-hidden="true" viewBox="0 0 16 16" width="14" height="14"><path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.193a.75.75 0 0 1-1.088.79L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194-3.047-2.97a.75.75 0 0 1 .416-1.278l4.21-.612L7.327.668A.75.75 0 0 1 8 .25Z"/></svg>
319+ <span data-github-star-count></span>
320+ </span>
321+ </a>
314322 <button class="icon-button theme-button" type="button" aria-label="Change color theme" title="Change color theme">Theme</button>
315323 </div>
316324 </header>`
325+ }
326+
327+ export const githubRepository = ( value ) => {
328+ const url = new URL ( value )
329+ const segments = url . pathname . split ( "/" ) . filter ( Boolean )
330+ if ( url . protocol !== "https:" || url . hostname !== "github.com" || segments . length !== 2 ) {
331+ throw new Error ( `Expected a GitHub repository URL, received ${ value } ` )
332+ }
333+ return segments . join ( "/" )
334+ }
317335
318336const renderNavigation = ( site , currentRoute ) => `
319337 <aside class="module-navigation" id="module-navigation" aria-label="API modules" data-pagefind-ignore>
0 commit comments