supMDX/core/page/MetaInfo.tsx
2023-02-16 09:54:31 +09:00

19 lines
404 B
TypeScript

import React from 'react';
export type MetaInfoProps = {
data: Record<string, any>
fields: {
label: string
attr: string
}[]
};
export function MetaInfo({fields, data}: MetaInfoProps) {
return <div>{fields.map(({label, attr}) => {
const val = data[attr];
return val == null ? null : <div key={attr}>
<span>{label}</span>
<span>{val}</span>
</div>;
})}</div>;
}