mirror of
https://github.com/covidpass-org/covidpass.git
synced 2025-02-22 06:27:49 +01:00
function for handling url parsing in FAQ
This commit is contained in:
parent
d1f70167b6
commit
2030ebf729
@ -4,6 +4,26 @@ import {serverSideTranslations} from 'next-i18next/serverSideTranslations';
|
||||
import Page from '../components/Page'
|
||||
import Card from '../components/Card'
|
||||
|
||||
interface link{
|
||||
url: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
function linkToJSX(link: link): JSX.Element {
|
||||
return <div style={{ display: 'inline' }} dangerouslySetInnerHTML={{ __html: `<a href="${link.url}" target="_blank" class="underline">${link.text}</a>` }}></div>
|
||||
}
|
||||
|
||||
function urlParse(text: string, links: link[]): JSX.Element[] {
|
||||
const el = text.split(/(%s)/).map(s => {
|
||||
if (s.includes("%s")) {
|
||||
return linkToJSX(links.pop());
|
||||
} else {
|
||||
return <>{s}</>
|
||||
}
|
||||
});
|
||||
return el;
|
||||
}
|
||||
|
||||
function Faq(): JSX.Element {
|
||||
const { t } = useTranslation(['common', 'index', 'faq']);
|
||||
const questionList = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user