MCPcopy Create free account
hub / github.com/027xiguapi/code-box / Markdown

Function Markdown

contents/md.tsx:11–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9}
10
11export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected