import User from './pages/User';
import AlttpBaseRomProvider from '../helpers/AlttpBaseRomContext';
import UserContext from '../helpers/UserContext';
+import i18n from '../i18n';
const App = () => {
const [user, setUser] = useState(null);
<AlttpBaseRomProvider>
<UserContext.Provider value={user}>
<Helmet>
+ <html lang={i18n.language} />
<title>{t('general.appName')}</title>
<meta name="description" content={t('general.appDescription')} />
</Helmet>
const LanguageSwitcher = ({ user }) =>
<Button
- onClick={() => { setLanguage(user, i18n.language === 'de' ? 'en' : 'de'); }}
+ href={`?lng=${i18n.language === 'de' ? 'en' : 'de'}`}
+ onClick={e => { setLanguage(user, i18n.language === 'de' ? 'en' : 'de'); e.preventDefault(); }}
title={i18n.language === 'de' ? 'Switch to english' : 'Auf deutsch wechseln'}
variant="outline-secondary"
>
import Loading from '../common/Loading';
import NotFound from '../pages/NotFound';
import Detail from '../techniques/Detail';
-import { getTranslation } from '../../helpers/Technique';
+import { getLanguages, getTranslation } from '../../helpers/Technique';
import i18n from '../../i18n';
const Technique = () => {
<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 const hasRelations = (tech, type) => getRelations(tech, type).length > 0;
+export const getLanguages = tech => ['en', ...tech.translations.map(t => t.locale)];
+
export const getTranslation = (tech, prop, lang) => {
const direct = tech.translations.find(t => t.locale === lang);
if (direct) {
export default {
compareTranslation,
+ getLanguages,
getRelations,
getTranslation,
hasRelations,