]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/User.js
more alternate/canonical links
[alttp.git] / resources / js / components / pages / User.js
index 8dfdba45311aa410a0fbd0a858f3278bf4182912..144e4c01d86418c46bd16cc53f567556399420b8 100644 (file)
@@ -1,7 +1,9 @@
 import axios from 'axios';
 import React, { useEffect, useState } from 'react';
+import { Helmet } from 'react-helmet';
 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';
@@ -18,8 +20,9 @@ const User = () => {
 
        useEffect(() => {
                setLoading(true);
+               const ctrl = new AbortController();
                axios
-                       .get(`/api/users/${id}`)
+                       .get(`/api/users/${id}`, { signal: ctrl.signal })
                        .then(response => {
                                setError(null);
                                setLoading(false);
@@ -30,6 +33,9 @@ const User = () => {
                                setLoading(false);
                                setUser(null);
                        });
+               return () => {
+                       ctrl.abort();
+               };
        }, [id]);
 
        useEffect(() => {
@@ -59,6 +65,10 @@ const User = () => {
        }
 
        return <ErrorBoundary>
+               <Helmet>
+                       <title>{user.nickname || user.username}</title>
+               </Helmet>
+               <CanonicalLinks base={`/users/${user.id}`} />
                <Profile user={user} />
        </ErrorBoundary>;
 };