-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Adds OpenJS Footer #8577
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?
Adds OpenJS Footer #8577
Changes from all commits
56ebca6
c385642
40010e9
556a98e
c335f65
aa4f93e
bb11fd4
e88d0df
6e48d5e
dcb5719
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,77 @@ | ||
| import { useTranslations } from 'next-intl'; | ||
|
|
||
| import Link from '#site/components/Link'; | ||
|
|
||
| import type { FC } from 'react'; | ||
|
|
||
| type LegalProps = { | ||
| footerLinks: Array<{ | ||
| text: string; | ||
| link: string; | ||
| translation: string; | ||
| }>; | ||
| }; | ||
|
|
||
| /** | ||
| * These keys match the following locations, and are kept in sync to lessen duplication: | ||
| * - translation keys within [locale].json components.containers.footer.links | ||
| * - keys within the large [locale].json components.containers.footer.legal paragraph | ||
| * - used directly to find the passed links from navigation.footerLinks | ||
| */ | ||
| const RICH_TRANSLATION_KEYS = [ | ||
| 'foundationName', | ||
| 'trademarkPolicy', | ||
| 'trademarkList', | ||
| 'termsOfUse', | ||
| 'privacyPolicy', | ||
| 'bylaws', | ||
| 'codeOfConduct', | ||
| 'cookiePolicy', | ||
| ]; | ||
|
|
||
| const WithLegal: FC<LegalProps> = ({ footerLinks }) => { | ||
| const t = useTranslations(); | ||
|
|
||
| /** | ||
| * Takes the footerLinks from navigation constants and returns the link based on the final part of the translation key. | ||
| * | ||
| * Example: { | ||
| "link": "https://openjsf.org/", | ||
| "text": "components.containers.footer.links.foundationName" | ||
| }, | ||
| * | ||
| * | ||
| * @param key the final part of a translation string | ||
| * @returns the link URL matching the translation key | ||
| */ | ||
| const getLinkFromTranslationKey = (key: string) => { | ||
| return footerLinks.find(link => link.text.split('.').pop() === key)?.link; | ||
| }; | ||
|
|
||
| const richComponents = RICH_TRANSLATION_KEYS.reduce( | ||
| (acc, key) => { | ||
| acc[key] = (chunks: React.ReactNode) => ( | ||
| <Link href={getLinkFromTranslationKey(key)}>{chunks}</Link> | ||
bmuenzenmeyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| return acc; | ||
| }, | ||
| {} as Record<string, (text: React.ReactNode) => React.ReactNode> | ||
| ); | ||
|
|
||
| return ( | ||
| <> | ||
| <p>{t.rich('components.containers.footer.legal', richComponents)}</p> | ||
MattIPv4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| <p> | ||
| {footerLinks.map((link, index) => ( | ||
| <span key={link.link}> | ||
| <Link href={link.link}>{link.translation}</Link> | ||
| {index < footerLinks.length - 1 && ' | '} | ||
| </span> | ||
| ))} | ||
| </p> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default WithLegal; | ||
|
Contributor
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. This file is the only place the new writing is placed. It's slightly duplicative between |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,16 @@ | |
| "components": { | ||
| "containers": { | ||
| "footer": { | ||
| "legal": "Copyright <foundationName>OpenJS Foundation</foundationName> and Node.js contributors. All rights reserved. The <foundationName>OpenJS Foundation</foundationName> has registered trademarks and uses trademarks. For a list of trademarks of the <foundationName>OpenJS Foundation</foundationName>, please see our <trademarkPolicy>Trademark Policy</trademarkPolicy> and <trademarkList>Trademark List</trademarkList>. Trademarks and logos not indicated on the <trademarkList>list of OpenJS Foundation trademarks</trademarkList> are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.", | ||
| "links": { | ||
|
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. Why we need these individual keys?
Contributor
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. The The openjs guidance is a paragraph with links and a list of links afterwards, which makes for duplication...somewhere. I've chosen to put the duplication in the translation strings rather than the code |
||
| "openJSFoundation": "OpenJS Foundation", | ||
| "trademarkPolicy": "Trademark Policy", | ||
| "foundationName": "OpenJS Foundation", | ||
| "termsOfUse": "Terms of Use", | ||
| "privacyPolicy": "Privacy Policy", | ||
| "bylaws": "Bylaws", | ||
| "codeOfConduct": "Code of Conduct", | ||
| "trademarkPolicy": "Trademark Policy", | ||
| "trademarkList": "Trademark List", | ||
| "cookiePolicy": "Cookie Policy", | ||
| "security": "Security Policy" | ||
|
Contributor
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. The retention of the security policy here means it is ADDED to the OpenJS footer. I think this is acceptable, as we purposely put it there at one point to expand visibility. |
||
| }, | ||
| "releasePills": { | ||
bmuenzenmeyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.