()
| 9 | } |
| 10 | |
| 11 | export default function Markdown() { |
| 12 | const [post, setPost] = useStorage({ |
| 13 | key: "md-post", |
| 14 | instance: new Storage({ |
| 15 | area: "local" |
| 16 | }) |
| 17 | }) |
| 18 | |
| 19 | useEffect(() => { |
| 20 | if (post) { |
| 21 | const posts = JSON.parse(window.localStorage.getItem("MD__posts")) || [] |
| 22 | const _post = JSON.parse(post) |
| 23 | |
| 24 | if (posts[0] && _post.content != posts[0].content) { |
| 25 | posts.unshift({ |
| 26 | content: _post.content, |
| 27 | title: _post.title || "Untitled" |
| 28 | }) |
| 29 | window.localStorage.setItem("MD__posts", JSON.stringify(posts)) |
| 30 | setPost("") |
| 31 | location.reload() |
| 32 | } |
| 33 | } |
| 34 | }, [post]) |
| 35 | |
| 36 | return <div style={{ display: "none" }}></div> |
| 37 | } |
nothing calls this directly
no outgoing calls
no test coverage detected