diff --git a/astro.config.mjs b/astro.config.mjs index 85bd53eb..6765e82b 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -27,6 +27,8 @@ export default defineConfig({ tableOfContents: { minHeadingLevel: 2, maxHeadingLevel: 4 }, components: { Footer: './src/components/overrides/Footer.astro', + Header: './src/components/overrides/Header.astro', + MobileMenuFooter: './src/components/overrides/MobileMenuFooter.astro', Sidebar: './src/components/overrides/Sidebar.astro', SocialIcons: './src/components/overrides/SocialIcons.astro' } diff --git a/cypress/e2e/release-badge.cy.js b/cypress/e2e/release-badge.cy.js new file mode 100644 index 00000000..e9cf6c2b --- /dev/null +++ b/cypress/e2e/release-badge.cy.js @@ -0,0 +1,38 @@ +const releaseUrl = + 'https://github.com/archivesspace/archivesspace/releases/latest' +const title = 'Go to the latest ArchivesSpace release' +const badgeSrc = `https://img.shields.io/github/v/release/archivesspace/archivesspace?label=ArchivesSpace&color=007595` +const altText = 'The latest ArchivesSpace release version' + +describe('Release Badge', () => { + it('displays the release badge with the correct data in the header on desktop', () => { + cy.visit('/') + cy.get( + '.page > header:first-child > div:first-child > div:nth-child(3) > a:first-child' + ) + .should('have.attr', 'href', releaseUrl) + .should('have.attr', 'title', title) + .within(() => { + cy.get('img') + .should('have.attr', 'src', badgeSrc) + .should('have.attr', 'alt', altText) + }) + }) + + it( + 'displays the release badge with the correct data in the mobile menu footer', + { viewportWidth: 400 }, + () => { + cy.visit('/') + cy.get('button[aria-label="Menu"]').click() + cy.get('#starlight__sidebar .mobile-preferences > a:first-child') + .should('have.attr', 'href', releaseUrl) + .should('have.attr', 'title', title) + .within(() => { + cy.get('img') + .should('have.attr', 'src', badgeSrc) + .should('have.attr', 'alt', altText) + }) + } + ) +}) diff --git a/src/components/ReleaseBadge.astro b/src/components/ReleaseBadge.astro new file mode 100644 index 00000000..c1f8ac95 --- /dev/null +++ b/src/components/ReleaseBadge.astro @@ -0,0 +1,28 @@ +--- +const releaseUrl = + 'https://github.com/archivesspace/archivesspace/releases/latest' +const label = 'ArchivesSpace' +const color = '007595' // dark `--sl-color-accent` via custom.css +const badgeSrc = `https://img.shields.io/github/v/release/archivesspace/archivesspace?label=${label}&color=${color}` +const altText = 'The latest ArchivesSpace release version' +const title = 'Go to the latest ArchivesSpace release' +--- + + + {altText} + + + diff --git a/src/components/overrides/Header.astro b/src/components/overrides/Header.astro new file mode 100644 index 00000000..2235b117 --- /dev/null +++ b/src/components/overrides/Header.astro @@ -0,0 +1,105 @@ +--- +// Via https://github.com/withastro/starlight/blob/23bf960aed36445600b6ccecb2138a5b461e2929/packages/starlight/components/Header.astro + +import config from 'virtual:starlight/user-config' +import type { Props } from '@astrojs/starlight/props' + +import LanguageSelect from '@astrojs/starlight/components/LanguageSelect.astro' +import Search from '@astrojs/starlight/components/Search.astro' +import SiteTitle from '@astrojs/starlight/components/SiteTitle.astro' +import ReleaseBadge from '../ReleaseBadge.astro' +import SocialIcons from './SocialIcons.astro' +import ThemeSelect from '@astrojs/starlight/components/ThemeSelect.astro' + +/** + * Render the `Search` component if Pagefind is enabled or the default search component has been overridden. + */ +const shouldRenderSearch = + config.pagefind || + config.components.Search !== '@astrojs/starlight/components/Search.astro' +--- + +
+
+ +
+
+ {shouldRenderSearch && } +
+
+ + + + +
+
+ + diff --git a/src/components/overrides/MobileMenuFooter.astro b/src/components/overrides/MobileMenuFooter.astro new file mode 100644 index 00000000..47675b08 --- /dev/null +++ b/src/components/overrides/MobileMenuFooter.astro @@ -0,0 +1,37 @@ +--- +// Via https://github.com/withastro/starlight/blob/490c6eff34ab408c4f55777b7b0caa16787dd3d4/packages/starlight/components/MobileMenuFooter.astro + +import type { Props } from '@astrojs/starlight/props' +import LanguageSelect from '@astrojs/starlight/components/LanguageSelect.astro' +import ReleaseBadge from '../ReleaseBadge.astro' +import SocialIcons from './SocialIcons.astro' +import ThemeSelect from '@astrojs/starlight/components/ThemeSelect.astro' +--- + +
+ + + + +
+ + diff --git a/src/utils/gitMetadata.mjs b/src/utils/gitMetadata.mjs index 5662d348..41020958 100644 --- a/src/utils/gitMetadata.mjs +++ b/src/utils/gitMetadata.mjs @@ -1,5 +1,5 @@ -import { exec } from 'child_process' -import { promisify } from 'util' +import { exec } from 'node:child_process' +import { promisify } from 'node:util' const execPromise = promisify(exec)