|
| 1 | +/* eslint-disable react/prop-types */ |
| 2 | +/** |
| 3 | + * Copyright (c) Facebook, Inc. and its affiliates. |
| 4 | + * |
| 5 | + * This source code is licensed under the MIT license found in the |
| 6 | + * LICENSE file in the root directory of this source tree. |
| 7 | + */ |
| 8 | +import type { FC } from 'react'; |
| 9 | +import React from 'react'; |
| 10 | +import Link from '@docusaurus/Link'; |
| 11 | +import useBaseUrl from '@docusaurus/useBaseUrl'; |
| 12 | +import { Icon } from '@iconify/react'; |
| 13 | +import githubIcon from '@iconify/icons-akar-icons/github-fill'; |
| 14 | +import twitterIcon from '@iconify/icons-akar-icons/twitter-fill'; |
| 15 | +import slackIcon from '@iconify/icons-akar-icons/slack-fill'; |
| 16 | +import youtubeIcon from '@iconify/icons-akar-icons/youtube-fill'; |
| 17 | +import { LazyLoadImage } from 'react-lazy-load-image-component'; |
| 18 | +import style from './styles.module.scss'; |
| 19 | + |
| 20 | +const footer = { |
| 21 | + links: [ |
| 22 | + { |
| 23 | + title: 'ASF', |
| 24 | + items: [ |
| 25 | + { |
| 26 | + label: 'Foundation', |
| 27 | + to: 'https://www.apache.org/', |
| 28 | + }, |
| 29 | + { |
| 30 | + label: 'License', |
| 31 | + to: 'https://www.apache.org/licenses/', |
| 32 | + }, |
| 33 | + { |
| 34 | + label: 'Events', |
| 35 | + to: 'https://www.apache.org/events/', |
| 36 | + }, |
| 37 | + { |
| 38 | + label: 'Security', |
| 39 | + to: 'https://www.apache.org/security/', |
| 40 | + }, |
| 41 | + { |
| 42 | + label: 'Sponsorship', |
| 43 | + to: 'https://www.apache.org/foundation/sponsorship.html', |
| 44 | + }, |
| 45 | + { |
| 46 | + label: 'Thanks', |
| 47 | + to: 'https://www.apache.org/foundation/thanks.html', |
| 48 | + }, |
| 49 | + ], |
| 50 | + }, |
| 51 | + { |
| 52 | + title: 'Community', |
| 53 | + items: [ |
| 54 | + { |
| 55 | + icon: githubIcon, |
| 56 | + label: 'GitHub', |
| 57 | + to: 'https://github.com/apache/apisix/issues', |
| 58 | + }, |
| 59 | + { |
| 60 | + icon: slackIcon, |
| 61 | + label: 'Slack', |
| 62 | + to: '/docs/general/join', |
| 63 | + }, |
| 64 | + { |
| 65 | + icon: twitterIcon, |
| 66 | + label: 'Twitter', |
| 67 | + to: 'https://twitter.com/ApacheAPISIX', |
| 68 | + }, |
| 69 | + { |
| 70 | + icon: youtubeIcon, |
| 71 | + label: 'YouTube', |
| 72 | + to: 'https://www.youtube.com/channel/UCgPD18cMhOg5rmPVnQhAC8g', |
| 73 | + }, |
| 74 | + ], |
| 75 | + }, |
| 76 | + { |
| 77 | + title: 'More', |
| 78 | + items: [ |
| 79 | + { |
| 80 | + label: 'Blog', |
| 81 | + to: '/blog/', |
| 82 | + }, { |
| 83 | + label: 'Showcase', |
| 84 | + to: '/showcase', |
| 85 | + }, { |
| 86 | + label: 'Plugin Hub', |
| 87 | + to: '/plugins', |
| 88 | + }, |
| 89 | + ], |
| 90 | + }, |
| 91 | + ], |
| 92 | + logo: { |
| 93 | + alt: 'Apache Software Foundation', |
| 94 | + src: 'https://static.apiseven.com/202202/asf_logo_wide_small.png', |
| 95 | + href: 'https://www.apache.org/', |
| 96 | + }, |
| 97 | + |
| 98 | + copyright: |
| 99 | + 'Copyright © 2019-2022 The Apache Software Foundation. Apache APISIX, APISIX®, Apache, the Apache feather logo, and the Apache APISIX project logo are either registered trademarks or trademarks of the Apache Software Foundation.', |
| 100 | +}; |
| 101 | + |
| 102 | +const FooterLink = ({ |
| 103 | + to, icon, href, label, prependBaseUrlToHref, ...props |
| 104 | +}) => { |
| 105 | + const toUrl = useBaseUrl(to); |
| 106 | + const normalizedHref = useBaseUrl(href, { |
| 107 | + forcePrependBaseUrl: true, |
| 108 | + }); |
| 109 | + const hrefObj = href |
| 110 | + ? { href: prependBaseUrlToHref ? normalizedHref : href } |
| 111 | + : { to: toUrl }; |
| 112 | + return ( |
| 113 | + <Link |
| 114 | + {...hrefObj} |
| 115 | + {...props} |
| 116 | + > |
| 117 | + <Icon icon={icon} /> |
| 118 | + <span>{label}</span> |
| 119 | + </Link> |
| 120 | + ); |
| 121 | +}; |
| 122 | + |
| 123 | +const Footer: FC = () => { |
| 124 | + const { copyright, links, logo } = footer; |
| 125 | + |
| 126 | + if (!footer) { |
| 127 | + return null; |
| 128 | + } |
| 129 | + |
| 130 | + return ( |
| 131 | + <footer className={style.container}> |
| 132 | + {links && links.length > 0 && ( |
| 133 | + <div className={style.linksRow}> |
| 134 | + {links.map(({ title, items }) => ( |
| 135 | + <div key={title} className={style.linksCol}> |
| 136 | + <div>{title}</div> |
| 137 | + <ul> |
| 138 | + {items.map((v) => ( |
| 139 | + <li key={v.to} className="footer__item"> |
| 140 | + <FooterLink {...v} /> |
| 141 | + </li> |
| 142 | + ))} |
| 143 | + </ul> |
| 144 | + </div> |
| 145 | + ))} |
| 146 | + </div> |
| 147 | + )} |
| 148 | + <div className={style.copyright}> |
| 149 | + <Link href={logo.href}> |
| 150 | + <LazyLoadImage alt={logo.alt} src={logo.src} height="40px" width="231.25px" /> |
| 151 | + </Link> |
| 152 | + <div className={style.text}>{copyright}</div> |
| 153 | + </div> |
| 154 | + </footer> |
| 155 | + ); |
| 156 | +}; |
| 157 | + |
| 158 | +export default Footer; |
0 commit comments