2021-03-29 05:41:10 +02:00
|
|
|
import React from 'react';
|
2021-03-29 03:57:22 +02:00
|
|
|
import ReactMarkdown from 'react-markdown';
|
2021-03-29 16:13:31 +02:00
|
|
|
import { useRouter } from 'next/router';
|
2021-03-29 04:10:33 +02:00
|
|
|
import { Header } from '../component/header';
|
2021-03-29 05:32:35 +02:00
|
|
|
import { Email } from '../component/email';
|
2021-03-29 03:57:22 +02:00
|
|
|
import md from '../faq.md';
|
2021-03-29 16:13:31 +02:00
|
|
|
import { tracker } from '../analytics';
|
2021-03-29 16:41:34 +02:00
|
|
|
import { t, m } from '../i18n';
|
2021-03-29 03:57:22 +02:00
|
|
|
|
2021-03-29 05:41:10 +02:00
|
|
|
function flatten(text, child) {
|
|
|
|
return typeof child === 'string'
|
|
|
|
? text + child
|
|
|
|
: React.Children.toArray(child.props.children).reduce(flatten, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
function HeadingRenderer(props) {
|
|
|
|
var children = React.Children.toArray(props.children);
|
|
|
|
var text = children.reduce(flatten, '');
|
|
|
|
var slug = text.toLowerCase().replace(/\W/g, '-');
|
|
|
|
return React.createElement('h' + props.level, { id: slug }, props.children);
|
|
|
|
}
|
|
|
|
|
2021-03-29 03:57:22 +02:00
|
|
|
export default function Faq() {
|
2021-03-29 16:13:31 +02:00
|
|
|
const router = useRouter();
|
|
|
|
const lang = router.query.lang || 'en';
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
2021-03-29 16:28:45 +02:00
|
|
|
tracker.trackPageView(window.location.pathname);
|
2021-03-29 16:13:31 +02:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
function __(message) {
|
|
|
|
return t(message, lang);
|
|
|
|
}
|
|
|
|
|
2021-03-29 03:57:22 +02:00
|
|
|
return (
|
2021-03-29 05:32:35 +02:00
|
|
|
<div>
|
2021-03-29 04:10:33 +02:00
|
|
|
<Header faqPage />
|
2021-03-29 05:32:35 +02:00
|
|
|
|
|
|
|
<main>
|
|
|
|
<div className="content md">
|
2021-03-29 05:41:10 +02:00
|
|
|
<ReactMarkdown renderers={{ heading: HeadingRenderer }}>
|
|
|
|
{md}
|
|
|
|
</ReactMarkdown>
|
2021-03-29 05:32:35 +02:00
|
|
|
</div>
|
|
|
|
|
2021-03-29 16:13:31 +02:00
|
|
|
<Email i18n={__} />
|
2021-03-29 05:32:35 +02:00
|
|
|
</main>
|
|
|
|
</div>
|
2021-03-29 03:57:22 +02:00
|
|
|
);
|
|
|
|
}
|