mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* metadata helpers and values for txs pages * update titles to the rest of the pages * refactor getServerSideProps * dynamically update metadata for token and dapp page * test * 404 error page
17 lines
404 B
TypeScript
17 lines
404 B
TypeScript
export default function compileValue(template: string, params: Record<string, string | Array<string> | undefined>) {
|
|
const PLACEHOLDER_REGEX = /%(\w+)%/g;
|
|
return template.replaceAll(PLACEHOLDER_REGEX, (match, p1) => {
|
|
const value = params[p1];
|
|
|
|
if (Array.isArray(value)) {
|
|
return value.join(', ');
|
|
}
|
|
|
|
if (value === undefined) {
|
|
return '';
|
|
}
|
|
|
|
return value;
|
|
});
|
|
}
|