From b7602df1cdee75d0814cf3f131b4906a31841851 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 10 Aug 2026 22:59:04 +0200 Subject: [PATCH] fix(theme): rendering of sponsor and team components inside vp-doc containers (#4493) Co-authored-by: Bjorn Lu Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- __tests__/e2e/.vitepress/config.ts | 22 +++++ __tests__/e2e/multi-sidebar/index.test.ts | 3 +- __tests__/e2e/public/sponsor-logo.svg | 4 + __tests__/e2e/public/team-avatar-small.svg | 5 ++ __tests__/e2e/public/team-avatar-wide.svg | 6 ++ __tests__/e2e/team-and-sponsors/data.ts | 89 +++++++++++++++++++ __tests__/e2e/team-and-sponsors/doc.md | 3 + .../home-no-markdown-styles.md | 30 +++++++ __tests__/e2e/team-and-sponsors/home.md | 29 ++++++ __tests__/e2e/team-and-sponsors/page.md | 8 ++ .../team-and-sponsors/parts/doc-page-body.md | 42 +++++++++ .../e2e/team-and-sponsors/parts/home-body.md | 47 ++++++++++ .../theme-default/components/VPButton.vue | 3 +- .../theme-default/components/VPHome.vue | 1 + .../components/VPHomeContent.vue | 26 +----- .../components/VPHomeSponsors.vue | 2 + .../components/VPTeamMembers.vue | 18 ++++ .../components/VPTeamMembersItem.vue | 5 ++ .../components/VPTeamPageSection.vue | 2 + .../styles/components/vp-doc.css | 23 ----- .../styles/components/vp-sponsor.css | 19 ++-- 21 files changed, 332 insertions(+), 55 deletions(-) create mode 100644 __tests__/e2e/public/sponsor-logo.svg create mode 100644 __tests__/e2e/public/team-avatar-small.svg create mode 100644 __tests__/e2e/public/team-avatar-wide.svg create mode 100644 __tests__/e2e/team-and-sponsors/data.ts create mode 100644 __tests__/e2e/team-and-sponsors/doc.md create mode 100644 __tests__/e2e/team-and-sponsors/home-no-markdown-styles.md create mode 100644 __tests__/e2e/team-and-sponsors/home.md create mode 100644 __tests__/e2e/team-and-sponsors/page.md create mode 100644 __tests__/e2e/team-and-sponsors/parts/doc-page-body.md create mode 100644 __tests__/e2e/team-and-sponsors/parts/home-body.md diff --git a/__tests__/e2e/.vitepress/config.ts b/__tests__/e2e/.vitepress/config.ts index 7ec72c30..cafcfd50 100644 --- a/__tests__/e2e/.vitepress/config.ts +++ b/__tests__/e2e/.vitepress/config.ts @@ -132,6 +132,27 @@ const sidebar: DefaultTheme.Config['sidebar'] = { link: '/markdown-extensions/foo' } ] + }, + { + text: 'Team & Sponsors', + items: [ + { + text: 'Doc Layout', + link: '/team-and-sponsors/doc' + }, + { + text: 'Page Layout', + link: '/team-and-sponsors/page' + }, + { + text: 'Home Layout', + link: '/team-and-sponsors/home' + }, + { + text: 'Home Layout (raw markdown)', + link: '/team-and-sponsors/home-no-markdown-styles' + } + ] } ], '/multi-sidebar/': [ @@ -154,6 +175,7 @@ const sidebar: DefaultTheme.Config['sidebar'] = { export default defineConfig({ title: 'Example', description: 'An example app using VitePress.', + srcExclude: ['**/parts/**'], markdown: { image: { lazyLoad: true } }, diff --git a/__tests__/e2e/multi-sidebar/index.test.ts b/__tests__/e2e/multi-sidebar/index.test.ts index b6482bdb..cd654301 100644 --- a/__tests__/e2e/multi-sidebar/index.test.ts +++ b/__tests__/e2e/multi-sidebar/index.test.ts @@ -15,7 +15,8 @@ describe('test multi sidebar sort root', () => { 'Data Loading', 'Multi Sidebar Test', 'Dynamic Routes', - 'Markdown Extensions' + 'Markdown Extensions', + 'Team & Sponsors' ]) }) }) diff --git a/__tests__/e2e/public/sponsor-logo.svg b/__tests__/e2e/public/sponsor-logo.svg new file mode 100644 index 00000000..1349e88e --- /dev/null +++ b/__tests__/e2e/public/sponsor-logo.svg @@ -0,0 +1,4 @@ + + + SPONSOR + diff --git a/__tests__/e2e/public/team-avatar-small.svg b/__tests__/e2e/public/team-avatar-small.svg new file mode 100644 index 00000000..43e062b0 --- /dev/null +++ b/__tests__/e2e/public/team-avatar-small.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/__tests__/e2e/public/team-avatar-wide.svg b/__tests__/e2e/public/team-avatar-wide.svg new file mode 100644 index 00000000..316cdfeb --- /dev/null +++ b/__tests__/e2e/public/team-avatar-wide.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/__tests__/e2e/team-and-sponsors/data.ts b/__tests__/e2e/team-and-sponsors/data.ts new file mode 100644 index 00000000..fd0bee00 --- /dev/null +++ b/__tests__/e2e/team-and-sponsors/data.ts @@ -0,0 +1,89 @@ +import type { DefaultTheme } from 'vitepress/theme' + +export const members: DefaultTheme.TeamMember[] = [ + { + // smaller than the rendered avatar, checks that it still fills the circle + avatar: '/team-avatar-small.svg', + name: 'Alice Example', + title: 'Creator', + org: 'Example Org', + orgLink: 'https://example.com', + desc: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + links: [ + { icon: 'github', link: 'https://example.com' }, + { icon: 'x', link: 'https://example.com' } + ], + sponsor: 'https://example.com' + }, + { + // non-square, checks object-fit (side stripes must stay cropped out) + avatar: '/team-avatar-wide.svg', + name: 'Bob Example', + title: 'Maintainer', + links: [{ icon: 'github', link: 'https://example.com' }] + }, + { + avatar: '/team-avatar-small.svg', + name: 'Carol Example', + title: 'Partner' + } +] + +export const partners: DefaultTheme.TeamMember[] = [ + { + avatar: '/team-avatar-wide.svg', + name: 'Dave Example', + title: 'Partner', + links: [{ icon: 'github', link: 'https://example.com' }] + }, + { + avatar: '/team-avatar-small.svg', + name: 'Eve Example', + title: 'Partner' + }, + { + avatar: '/team-avatar-wide.svg', + name: 'Frank Example', + title: 'Partner' + } +] + +interface Sponsor { + name: string + img: string + url: string +} + +const sponsor = (name: string): Sponsor => ({ + name, + img: '/sponsor-logo.svg', + url: 'https://example.com' +}) + +export const sponsors: { + tier: string + size?: 'medium' | 'big' + items: Sponsor[] +}[] = [ + { + tier: 'Platinum Sponsors', + size: 'big', + items: [sponsor('Sponsor One'), sponsor('Sponsor Two')] + }, + { + tier: 'Gold Sponsors', + size: 'medium', + items: [ + sponsor('Sponsor Three'), + sponsor('Sponsor Four'), + sponsor('Sponsor Five'), + sponsor('Sponsor Six') + ] + } +] + +export const friends: Sponsor[] = [ + sponsor('Friend One'), + sponsor('Friend Two'), + sponsor('Friend Three') +] diff --git a/__tests__/e2e/team-and-sponsors/doc.md b/__tests__/e2e/team-and-sponsors/doc.md new file mode 100644 index 00000000..ac2abe67 --- /dev/null +++ b/__tests__/e2e/team-and-sponsors/doc.md @@ -0,0 +1,3 @@ +# Team & Sponsors in Doc Layout + + diff --git a/__tests__/e2e/team-and-sponsors/home-no-markdown-styles.md b/__tests__/e2e/team-and-sponsors/home-no-markdown-styles.md new file mode 100644 index 00000000..f536f96a --- /dev/null +++ b/__tests__/e2e/team-and-sponsors/home-no-markdown-styles.md @@ -0,0 +1,30 @@ +--- +layout: home +title: Team & Sponsors in Home Layout (no markdown styles) +markdownStyles: false + +hero: + name: Team & Sponsors + text: Home layout without markdown styles + tagline: Reference rendering of the components + actions: + - theme: brand + text: Doc Layout + link: ./doc + image: + src: /vitepress.png + alt: VitePress + +features: + - icon: 📝 + title: Feature A + details: Some details about feature A. + - icon: ⚡ + title: Feature B + details: Some details about feature B. + - icon: 🚀 + title: Feature C + details: Some details about feature C. +--- + + diff --git a/__tests__/e2e/team-and-sponsors/home.md b/__tests__/e2e/team-and-sponsors/home.md new file mode 100644 index 00000000..11e9030c --- /dev/null +++ b/__tests__/e2e/team-and-sponsors/home.md @@ -0,0 +1,29 @@ +--- +layout: home +title: Team & Sponsors in Home Layout + +hero: + name: Team & Sponsors + text: Home layout with markdown styles + tagline: Compare with the no-markdown-styles variant + actions: + - theme: brand + text: Doc Layout + link: ./doc + image: + src: /vitepress.png + alt: VitePress + +features: + - icon: 📝 + title: Feature A + details: Some details about feature A. + - icon: ⚡ + title: Feature B + details: Some details about feature B. + - icon: 🚀 + title: Feature C + details: Some details about feature C. +--- + + diff --git a/__tests__/e2e/team-and-sponsors/page.md b/__tests__/e2e/team-and-sponsors/page.md new file mode 100644 index 00000000..e1afb836 --- /dev/null +++ b/__tests__/e2e/team-and-sponsors/page.md @@ -0,0 +1,8 @@ +--- +layout: page +title: Team & Sponsors in Page Layout +--- + +# Team & Sponsors in Page Layout + + diff --git a/__tests__/e2e/team-and-sponsors/parts/doc-page-body.md b/__tests__/e2e/team-and-sponsors/parts/doc-page-body.md new file mode 100644 index 00000000..13c989f4 --- /dev/null +++ b/__tests__/e2e/team-and-sponsors/parts/doc-page-body.md @@ -0,0 +1,42 @@ + + +Regular paragraph with a [link](https://example.com) and `inline code`. + +## Small, One Member + + + +## Small, Two Members + + + +## Small, Three Members + + + +## Medium, One Member + + + +## Medium, Two Members + + + +## Medium, Three Members + + + +## Sponsors, Tiered + + + +## Sponsors, Single Tier + + + +## After Components + +Trailing markdown content after the components. diff --git a/__tests__/e2e/team-and-sponsors/parts/home-body.md b/__tests__/e2e/team-and-sponsors/parts/home-body.md new file mode 100644 index 00000000..f92190ce --- /dev/null +++ b/__tests__/e2e/team-and-sponsors/parts/home-body.md @@ -0,0 +1,47 @@ + + +## Markdown Section + +Some paragraph text with a [link](https://example.com) and `inline code` to +verify how markdown content is styled in this variant. + +- List item one +- List item two + + + + + + + + + + + + + + + + +## After Components + +Trailing markdown content after the components. diff --git a/src/client/theme-default/components/VPButton.vue b/src/client/theme-default/components/VPButton.vue index 9e8ea52d..ac062d7a 100644 --- a/src/client/theme-default/components/VPButton.vue +++ b/src/client/theme-default/components/VPButton.vue @@ -29,7 +29,7 @@ const component = computed(() => {