mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-07-05 09:21:39 +02:00
#124 - Add support to specify preview image
This commit is contained in:
@@ -13,10 +13,10 @@ import { DateTimeField } from './Fields/DateTimeField';
|
||||
import { TextField } from './Fields/TextField';
|
||||
import "react-datepicker/dist/react-datepicker.css";
|
||||
import { PreviewImageField } from './Fields/PreviewImageField';
|
||||
import { DEFAULT_CONTENT_TYPE, DEFAULT_CONTENT_TYPE_NAME } from '../../constants/ContentType';
|
||||
import { ListUnorderedIcon } from './Icons/ListUnorderedIcon';
|
||||
import { NumberField } from './Fields/NumberField';
|
||||
import { ChoiceField } from './Fields/ChoiceField';
|
||||
import useContentType from '../../hooks/useContentType';
|
||||
|
||||
export interface IMetadataProps {
|
||||
settings: PanelSettings | undefined;
|
||||
@@ -26,6 +26,7 @@ export interface IMetadataProps {
|
||||
}
|
||||
|
||||
export const Metadata: React.FunctionComponent<IMetadataProps> = ({settings, metadata, focusElm, unsetFocus}: React.PropsWithChildren<IMetadataProps>) => {
|
||||
const contentType = useContentType(settings, metadata);
|
||||
|
||||
const sendUpdate = (field: string | undefined, value: any) => {
|
||||
if (!field) {
|
||||
@@ -49,17 +50,6 @@ export const Metadata: React.FunctionComponent<IMetadataProps> = ({settings, met
|
||||
return null;
|
||||
}
|
||||
|
||||
const contentTypeName = metadata.type as string || DEFAULT_CONTENT_TYPE_NAME;
|
||||
let contentType = settings.contentTypes.find(ct => ct.name === contentTypeName);
|
||||
|
||||
if (!contentType) {
|
||||
contentType = settings.contentTypes.find(ct => ct.name === DEFAULT_CONTENT_TYPE_NAME);
|
||||
}
|
||||
|
||||
if (!contentType || !contentType.fields) {
|
||||
contentType = DEFAULT_CONTENT_TYPE;
|
||||
}
|
||||
|
||||
const renderFields = (ctFields: Field[]) => {
|
||||
if (!ctFields) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user