mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-07-06 01:41:48 +02:00
#281 - Do not automatically set dates to fm + remove date {{now}} field
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user