Last active
October 17, 2021 10:28
-
-
Save EdwardBock/bcafd4f36942dc3e778b1f9d7181a001 to your computer and use it in GitHub Desktop.
Add reading time field to document setting panel
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
import { registerPlugin } from "@wordpress/plugins"; | |
import { PluginDocumentSettingPanel } from "@wordpress/edit-post"; | |
import { TextControl } from "@wordpress/components"; | |
import {useReadingTime} from "./reading-time-hooks.js"; | |
registerPlugin( | |
"reading-time", | |
{ | |
render: ()=> { | |
const [value, setValue] = useReadingTime(); | |
return <PluginDocumentSettingPanel | |
title="Reading time" | |
> | |
<TextControl | |
label="Estimated time in minutes" | |
onChange={setValue} | |
value={value} | |
/> | |
</PluginDocumentSettingPanel> | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment