]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/Technique.js
add language references to tech pages
[alttp.git] / resources / js / components / pages / Technique.js
index 19b56b72829e3c0427505b3a2327483516c2fc54..aabb8d0780db86a73be7e50133fe66ac2a66d7c8 100644 (file)
@@ -1,5 +1,7 @@
 import axios from 'axios';
 import React, { useEffect, useState } from 'react';
+import { Helmet } from 'react-helmet';
+import { withTranslation } from 'react-i18next';
 import { useParams } from 'react-router-dom';
 
 import ErrorBoundary from '../common/ErrorBoundary';
@@ -7,6 +9,8 @@ import ErrorMessage from '../common/ErrorMessage';
 import Loading from '../common/Loading';
 import NotFound from '../pages/NotFound';
 import Detail from '../techniques/Detail';
+import { getLanguages, getTranslation } from '../../helpers/Technique';
+import i18n from '../../i18n';
 
 const Technique = () => {
        const params = useParams();
@@ -25,7 +29,6 @@ const Technique = () => {
                                setError(null);
                                setLoading(false);
                                setTechnique(response.data);
-                               window.document.title = response.data.title;
                        })
                        .catch(error => {
                                setError(error);
@@ -50,8 +53,25 @@ const Technique = () => {
        }
 
        return <ErrorBoundary>
+               <Helmet>
+                       <title>{getTranslation(technique, 'title', i18n.language)}</title>
+                       <meta name="description" content={getTranslation(technique, 'short', i18n.language)} />
+                       <link
+                               href={`https://alttp.localhorst.tv/tech/${technique.name}`}
+                               hrefLang="x-default"
+                               rel="alternate"
+                       />
+                       {getLanguages(technique).map(l =>
+                               <link
+                                       key={l}
+                                       href={`https://alttp.localhorst.tv/tech/${technique.name}?lng=${l}`}
+                                       hrefLang={l}
+                                       rel="alternate"
+                               />
+                       )}
+               </Helmet>
                <Detail technique={technique} />
        </ErrorBoundary>;
 };
 
-export default Technique;
+export default withTranslation()(Technique);