From: Daniel Karbach Date: Wed, 15 Feb 2023 10:36:58 +0000 (+0100) Subject: more alternate/canonical links X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=8e274ddec45800cd727bb7138683b81cf2f7dcb1;p=alttp.git more alternate/canonical links --- diff --git a/resources/js/components/common/CanonicalLinks.js b/resources/js/components/common/CanonicalLinks.js new file mode 100644 index 0000000..26e8696 --- /dev/null +++ b/resources/js/components/common/CanonicalLinks.js @@ -0,0 +1,40 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import { Helmet } from 'react-helmet'; +import { useTranslation } from 'react-i18next'; + +const CanonicalLinks = ({ base, lang, langs }) => { + const { i18n } = useTranslation(); + + const activeLang = lang || i18n.language; + const availableLangs = langs || ['de', 'en']; + + return + + + {availableLangs.filter(l => l !== activeLang).map(l => + + )} + ; +}; + +CanonicalLinks.propTypes = { + base: PropTypes.string.isRequired, + lang: PropTypes.string, + langs: PropTypes.arrayOf(PropTypes.string), +}; + +export default CanonicalLinks; diff --git a/resources/js/components/pages/Front.js b/resources/js/components/pages/Front.js index 73b9b23..2ca43f2 100644 --- a/resources/js/components/pages/Front.js +++ b/resources/js/components/pages/Front.js @@ -2,6 +2,8 @@ import React from 'react'; import { Button, Col, Container, Image, Row } from 'react-bootstrap'; import { useNavigate } from 'react-router-dom'; +import CanonicalLinks from '../common/CanonicalLinks'; + const Front = () => { const navigate = useNavigate(); @@ -14,6 +16,7 @@ const Front = () => { }, []); return +