lbry-sec/pages/faq.js

37 lines
928 B
JavaScript
Raw Normal View History

import React from 'react';
2021-03-29 03:57:22 +02:00
import ReactMarkdown from 'react-markdown';
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';
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() {
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">
<ReactMarkdown renderers={{ heading: HeadingRenderer }}>
{md}
</ReactMarkdown>
2021-03-29 05:32:35 +02:00
</div>
<Email />
</main>
</div>
2021-03-29 03:57:22 +02:00
);
}