-
Notifications
You must be signed in to change notification settings - Fork 51
feat: sponsorship & sidebar improvements #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import MetaBar from '@node-core/ui-components/Containers/MetaBar'; | ||
| import AvatarGroup from '@node-core/ui-components/Common/AvatarGroup'; | ||
| import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub'; | ||
|
|
||
| import { editURL } from '#theme/config'; | ||
| import sponsors from '#theme/sponsors' with { type: 'json' }; | ||
| import SponsorCard from '../Sponsors/Card/index.jsx'; | ||
|
|
||
| // Active recurring platinum-tier sponsors, ranked by monthly amount. There are | ||
| // only ever a handful, so the MetaBar features them as full expanded cards. | ||
| const platinumSponsors = sponsors.sponsors | ||
| .filter(sponsor => sponsor.monthly.tier === 'platinum') | ||
| .sort((a, b) => b.monthly.value - a.monthly.value); | ||
|
|
||
| export default ({ metadata, headings = [], readingTime }) => { | ||
| const editThisPage = | ||
| metadata.source ?? editURL.replace('{path}', metadata.path); | ||
| const authors = metadata.authors?.split(',').map(id => ({ | ||
| image: `https://avatars.githubusercontent.com/${id.trim()}`, | ||
| url: `https://github.com/${id.trim()}`, | ||
| nickname: id, | ||
| })); | ||
|
|
||
| return ( | ||
| <MetaBar | ||
| heading="Table of Contents" | ||
| headings={{ items: headings }} | ||
| items={{ | ||
| 'Reading Time': readingTime, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we not use spreading please 🙇 Simply make a Map (or Record) and add items based on the criteria/validation, and then simply pass the record to items={{}}
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spreading is what we use elsewhere, for instance, in |
||
| ...(CLIENT && authors?.length | ||
| ? { | ||
| Authors: <AvatarGroup avatars={authors} as="a" limit={5} />, | ||
| } | ||
| : {}), | ||
| Contribute: ( | ||
| <> | ||
| <GitHubIcon className="fill-neutral-700 dark:fill-neutral-100" /> | ||
| <a href={editThisPage}>Edit this page</a> | ||
| </> | ||
| ), | ||
| ...(platinumSponsors.length | ||
| ? { | ||
| [platinumSponsors.length > 1 | ||
| ? 'Featured Sponsors' | ||
| : 'Featured Sponsor']: ( | ||
| <div className="flex w-full flex-col gap-3"> | ||
| {platinumSponsors.map(sponsor => ( | ||
| <SponsorCard | ||
| key={sponsor.slug} | ||
| sponsor={sponsor} | ||
| size="sm" | ||
| showAmount={false} | ||
| /> | ||
| ))} | ||
| </div> | ||
| ), | ||
| } | ||
| : {}), | ||
| }} | ||
| /> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,26 +6,28 @@ const redirect = url => (window.location.href = url); | |
|
|
||
| const PrefetchLink = props => <a {...props} rel="prefetch" />; | ||
|
|
||
| const pathnameFor = path => path.replace(/\/index$/, '') || '/'; | ||
| const pathnameFor = path => { | ||
| const clean = path.replace(/\/index$/, ''); | ||
| if (!clean) return '/'; | ||
| return clean.startsWith('/') ? clean : `/${clean}`; | ||
| }; | ||
|
|
||
| const groupsFor = path => { | ||
| if (Array.isArray(sidebar)) return sidebar; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should consistently use {} or not, I recall on nodejs.org we do that, unsure if we should also keep same consistency over here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't, at the moment |
||
|
|
||
| const segment = path.split('/').filter(Boolean)[0]; | ||
| const matched = sidebar.filter(g => g.groupName.toLowerCase() === segment); | ||
| return matched.length > 0 ? matched : sidebar; | ||
| return sidebar[segment] ?? []; | ||
| }; | ||
|
|
||
| /** | ||
| * Sidebar component for MDX documentation with page navigation. | ||
| */ | ||
| export default ({ metadata }) => { | ||
| const path = pathnameFor(metadata.path); | ||
| return ( | ||
| <SideBar | ||
| pathname={path} | ||
| groups={groupsFor(path)} | ||
| onSelect={redirect} | ||
| as={PrefetchLink} | ||
| title="Navigation" | ||
| /> | ||
| ); | ||
| }; | ||
| export default ({ metadata }) => ( | ||
| <SideBar | ||
| pathname={pathnameFor(metadata.path)} | ||
| groups={groupsFor(metadata.path)} | ||
| onSelect={redirect} | ||
| as={PrefetchLink} | ||
| title="Navigation" | ||
| /> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import BaseButton from '@node-core/ui-components/Common/BaseButton'; | |
|
|
||
| import NavBar from '../../components/NavBar.jsx'; | ||
| import Footer from '../../components/Footer/index.jsx'; | ||
| import SideBar from '../../components/SideBar.jsx'; | ||
| import SectionHeader from '../../components/SectionHeader/index.jsx'; | ||
| import SponsorTier from '../../components/Sponsors/Tier/index.jsx'; | ||
| import BackerWall from '../../components/Sponsors/BackerWall/index.jsx'; | ||
|
|
@@ -73,54 +74,60 @@ export default function SponsorsLayout({ metadata }) { | |
| <> | ||
| <NavBar metadata={metadata} /> | ||
|
|
||
| <main className={styles.page}> | ||
| <section className={styles.sponsorsSection}> | ||
| <div className={styles.container}> | ||
| <SectionHeader | ||
| eyebrow="Our sponsors" | ||
| title="The organizations behind webpack" | ||
| /> | ||
| <div className={styles.actions}> | ||
| <BaseButton | ||
| href={OC_URL} | ||
| target="_blank" | ||
| rel="noreferrer noopener" | ||
| kind="primary" | ||
| > | ||
| View on Open Collective | ||
| </BaseButton> | ||
| </div> | ||
| <div className={styles.toolbar}> | ||
| <SortToggle value={metric} onChange={setMetric} /> | ||
| </div> | ||
| <div className={styles.tiers}> | ||
| {TIERS.map(tier => ( | ||
| <SponsorTier | ||
| key={tier.tier} | ||
| tier={tier.tier} | ||
| label={tier.label} | ||
| price={tier.price[metric]} | ||
| cardSize={tier.cardSize} | ||
| sponsors={buckets[tier.tier]} | ||
| metric={metric} | ||
| /> | ||
| ))} | ||
| <div className={styles.shell}> | ||
| <aside className={styles.sidebar}> | ||
| <SideBar metadata={metadata} /> | ||
| </aside> | ||
|
|
||
| <main className={styles.page}> | ||
| <section className={styles.sponsorsSection}> | ||
| <div className={styles.container}> | ||
| <SectionHeader | ||
| eyebrow="Our sponsors" | ||
| title="The organizations supporting webpack" | ||
| /> | ||
| <div className={styles.actions}> | ||
| <BaseButton | ||
| href={OC_URL} | ||
| target="_blank" | ||
| rel="noreferrer noopener" | ||
| kind="primary" | ||
| > | ||
| View on Open Collective | ||
| </BaseButton> | ||
| </div> | ||
| <div className={styles.toolbar}> | ||
| <SortToggle value={metric} onChange={setMetric} /> | ||
| </div> | ||
| <div className={styles.tiers}> | ||
| {TIERS.map(tier => ( | ||
| <SponsorTier | ||
| key={tier.tier} | ||
| tier={tier.tier} | ||
| label={tier.label} | ||
| price={tier.price[metric]} | ||
| cardSize={tier.cardSize} | ||
| sponsors={buckets[tier.tier]} | ||
| metric={metric} | ||
|
Comment on lines
+104
to
+111
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of showing the amount they're contributing, could we sort them by contribution amount from highest to lowest, or even display them randomly? I do think we shouldn't show the contribution amount in that sidebar section. |
||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| </section> | ||
|
|
||
| <section className={styles.backersSection}> | ||
| <div className={styles.container}> | ||
| <SectionHeader | ||
| eyebrow="Our backers" | ||
| title="And the people who chip in" | ||
| /> | ||
| <div className={styles.backersBody}> | ||
| <BackerWall backers={data.backers} /> | ||
| <section className={styles.backersSection}> | ||
| <div className={styles.container}> | ||
| <SectionHeader | ||
| eyebrow="Our backers" | ||
| title="And the people who chip in" | ||
| /> | ||
| <div className={styles.backersBody}> | ||
| <BackerWall backers={data.backers} /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| </main> | ||
| </section> | ||
| </main> | ||
| </div> | ||
|
|
||
| <Footer /> | ||
| </> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # About webpack | ||
|
|
||
| STUB |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Documentation | ||
|
|
||
| STUB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a Become a Sponsor button
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.