]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/Technique.js
more alternate/canonical links
[alttp.git] / resources / js / components / pages / Technique.js
index 8c202ed44ad1fce81a80e4b1f89e16481eff8944..c4be0666614eb932d5c22e5ae8ccbf0ffd3dc23b 100644 (file)
@@ -1,14 +1,16 @@
 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 CanonicalLinks from '../common/CanonicalLinks';
 import ErrorBoundary from '../common/ErrorBoundary';
 import ErrorMessage from '../common/ErrorMessage';
 import Loading from '../common/Loading';
 import NotFound from '../pages/NotFound';
 import Detail from '../techniques/Detail';
-import { getTranslation } from '../../helpers/Technique';
+import { getLanguages, getMatchedLocale, getTranslation } from '../../helpers/Technique';
 import i18n from '../../i18n';
 
 const Technique = () => {
@@ -39,12 +41,6 @@ const Technique = () => {
                };
        }, [name]);
 
-       useEffect(() => {
-               if (technique) {
-                       window.document.title = getTranslation(technique, 'title', i18n.language);
-               }
-       }, [technique, i18n.language]);
-
        if (loading) {
                return <Loading />;
        }
@@ -58,6 +54,15 @@ const Technique = () => {
        }
 
        return <ErrorBoundary>
+               <Helmet>
+                       <title>{getTranslation(technique, 'title', i18n.language)}</title>
+                       <meta name="description" content={getTranslation(technique, 'short', i18n.language)} />
+               </Helmet>
+               <CanonicalLinks
+                       base={`/tech/${technique.name}`}
+                       lang={getMatchedLocale(technique, i18n.language)}
+                       langs={getLanguages(technique)}
+               />
                <Detail technique={technique} />
        </ErrorBoundary>;
 };