-
-
Notifications
You must be signed in to change notification settings - Fork 21
docs: add sponsor feed to docs #341
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
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,122 @@ | ||
| <template> | ||
| <section | ||
| v-if="sponsors.length" | ||
| aria-labelledby="endev-sponsors-title" | ||
| class="EndevSponsors" | ||
| > | ||
| <div class="EndevSponsorsInner"> | ||
| <p id="endev-sponsors-title" class="EndevSponsorsTitle"> | ||
| Company sponsors | ||
| </p> | ||
| <div class="EndevSponsorsLogos"> | ||
| <a | ||
| v-for="sponsor in sponsors" | ||
| :key="sponsor.name" | ||
| :aria-label="sponsor.name" | ||
| class="EndevSponsorsLogo" | ||
| :href="sponsor.url" | ||
| rel="noopener noreferrer" | ||
| target="_blank" | ||
| > | ||
| <img :alt="sponsor.name" :src="sponsor.logo" /> | ||
| </a> | ||
| </div> | ||
| <a class="EndevSponsorsCta" href="https://en.dev/#contact"> | ||
| Sponsor the work | ||
| </a> | ||
| </div> | ||
| </section> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { onMounted, ref } from "vue"; | ||
|
|
||
| const sponsors = ref([]); | ||
|
|
||
| onMounted(async () => { | ||
| try { | ||
| const res = await fetch("https://en.dev/sponsors.json", { | ||
| headers: { Accept: "application/json" }, | ||
| }); | ||
| if (!res.ok) return; | ||
|
|
||
| const payload = await res.json(); | ||
| sponsors.value = (Array.isArray(payload.sponsors) ? payload.sponsors : []) | ||
| .filter((sponsor) => | ||
| sponsor?.kind !== "infrastructure" && | ||
| sponsor?.name && | ||
| sponsor?.url && | ||
| sponsor?.logo | ||
| ); | ||
|
Comment on lines
+45
to
+50
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.
|
||
| } catch { | ||
| sponsors.value = []; | ||
| } | ||
| }); | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .EndevSponsors { | ||
| border-top: 1px solid var(--vp-c-divider); | ||
| padding: 22px 24px; | ||
| } | ||
|
|
||
| .EndevSponsorsInner { | ||
| align-items: center; | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| gap: 12px 18px; | ||
| justify-content: center; | ||
| margin: 0 auto; | ||
| max-width: 960px; | ||
| } | ||
|
|
||
| .EndevSponsorsTitle { | ||
| color: var(--vp-c-text-2); | ||
| font-size: 13px; | ||
| font-weight: 600; | ||
| margin: 0; | ||
| text-transform: uppercase; | ||
| } | ||
|
|
||
| .EndevSponsorsLogos { | ||
| align-items: center; | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| gap: 10px; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .EndevSponsorsLogo { | ||
| align-items: center; | ||
| border: 1px solid var(--vp-c-divider); | ||
| border-radius: 8px; | ||
| display: inline-flex; | ||
| height: 40px; | ||
| justify-content: center; | ||
| padding: 8px 12px; | ||
| transition: border-color 0.2s ease, background-color 0.2s ease; | ||
| } | ||
|
|
||
| .EndevSponsorsLogo:hover { | ||
| background: var(--vp-c-bg-soft); | ||
| border-color: var(--vp-c-brand-1); | ||
| } | ||
|
|
||
| .EndevSponsorsLogo img { | ||
| display: block; | ||
| max-height: 22px; | ||
| max-width: 120px; | ||
| } | ||
|
|
||
| .EndevSponsorsCta { | ||
| color: var(--vp-c-text-2); | ||
| font-size: 13px; | ||
| font-weight: 500; | ||
| text-decoration: none; | ||
| transition: color 0.2s ease; | ||
| } | ||
|
|
||
| .EndevSponsorsCta:hover { | ||
| color: var(--vp-c-brand-1); | ||
| } | ||
| </style> | ||
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.
sponsor.nameis not a reliablev-forkeyNames are not guaranteed to be unique across sponsors, and Vue will warn (and may misreconcile the virtual DOM) on duplicate keys. Since
sponsor.urlis already validated as present by the filter and is inherently unique per sponsor, prefer using it as the key instead ofsponsor.name.