add AppContext for state management and update ResourcesView to utilize context

This commit is contained in:
2025-05-23 21:53:39 +08:00
parent 81053d56f7
commit 4038683a56
5 changed files with 53 additions and 5 deletions

View File

@@ -232,7 +232,7 @@ function Article({ resource }: { resource: ResourceDetails }) {
if (!resource.related) {
return;
}
for (let child of articleRef.current.children) {
for (const child of articleRef.current.children) {
if (child.tagName === "P" && child.children.length === 1 && child.children[0].tagName === "A") {
const href = (child.children[0] as HTMLAnchorElement).href as string
if (href.startsWith(window.location.origin) || href.startsWith("/")) {
@@ -279,7 +279,7 @@ function Article({ resource }: { resource: ResourceDetails }) {
}
}
}
}, [resource])
}, [navigate, resource])
return <article ref={articleRef}>
<Markdown>{resource.article}</Markdown>