Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joel Huggett
committed
Jul 30, 2020
1 parent
36daf13
commit 6e54196
Showing
2 changed files
with
17 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
import { useCMS } from "tinacms" | ||
import { useEffect } from "react" | ||
import createDecorator from "final-form-calculate" | ||
import { formatDate } from "./blog_helpers" | ||
|
||
|
||
export function useLastEdited(form) { | ||
const cms = useCMS() | ||
const cms = useCMS() | ||
|
||
useEffect(() => { | ||
if (cms.disabled) { return } | ||
const decorator = createDecorator( | ||
{ | ||
field: /.*/, | ||
updates: { | ||
'frontmatter.last_edited': () => (new Date()).toISOString() | ||
} | ||
} | ||
) | ||
return decorator(form.finalForm) | ||
}, [form.id]) | ||
useEffect(() => { | ||
if (cms.disabled) { return } | ||
const decorator = createDecorator( | ||
{ | ||
field: /.*/, | ||
updates: { | ||
'frontmatter.last_edited': () => (new Date()).toISOString() | ||
} | ||
} | ||
) | ||
return decorator(form.finalForm) | ||
}, [form.id]) | ||
} |