#281 - Do not automatically set dates to fm + remove date {{now}} field

This commit is contained in:
Elio Struyf
2022-03-08 08:24:14 +01:00
parent 9340568653
commit c8e79e75ba
5 changed files with 11 additions and 6 deletions
+2 -1
View File
@@ -150,7 +150,8 @@ export class Article {
): ParsedFrontMatter | undefined {
const article = ArticleHelper.getFrontMatterFromDocument(document);
if (!article) {
// Only set the date, if there is already front matter set
if (!article || !article.data || Object.keys(article.data).length === 0) {
return;
}
+2 -2
View File
@@ -1,10 +1,10 @@
import { useState, useEffect, useCallback, useMemo } from 'react';
import { DEFAULT_CONTENT_TYPE, DEFAULT_CONTENT_TYPE_NAME } from '../constants/ContentType';
import { Settings } from '../dashboardWebView/models';
import { ContentType, Field, PanelSettings } from '../models';
import { ContentType, PanelSettings } from '../models';
export default function useContentType(settings: PanelSettings | Settings | undefined | null, metadata: any) {
const [contentType, setContentType] = useState<ContentType>(DEFAULT_CONTENT_TYPE);
const [contentType, setContentType] = useState<ContentType | null>(null);
useEffect(() => {
if (settings) {
+1 -1
View File
@@ -134,7 +134,7 @@ export class DataListener extends BaseListener {
}
const article = ArticleHelper.getFrontMatter(editor);
if (!article || !article.data || Object.keys(article.data).length === 0) {
if (!article) {
return;
}
@@ -84,10 +84,14 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
value = field.default;
if (field.type === 'datetime') {
if (value === "{{now}}") {
value = new Date();
}
value = getDate(value) || null;
}
onSendUpdate(field.name, value, parentFields);
//onSendUpdate(field.name, value, parentFields);
}
// Check if the field value contains a placeholder
+1 -1
View File
@@ -82,7 +82,7 @@ const Metadata: React.FunctionComponent<IMetadataProps> = ({settings, metadata,
<Collapsible id={`tags`} title="Metadata" className={`inherit z-20`}>
{
renderFields(contentType?.fields, metadata)
renderFields(contentType?.fields || [], metadata)
}
{