diff --git a/frontend/src/markdown.css b/frontend/src/markdown.css
index 2effb05..2b67a9e 100644
--- a/frontend/src/markdown.css
+++ b/frontend/src/markdown.css
@@ -1,6 +1,6 @@
article {
& {
- color: var(--color-base-content)
+ color: var(--color-base-content);
}
h1 {
@@ -92,9 +92,6 @@ article {
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, system-ui;
}
- .line-break {
- white-space: pre-wrap;
- }
iframe{
width: 100%;
height: 100%;
diff --git a/frontend/src/pages/resource_details_page.tsx b/frontend/src/pages/resource_details_page.tsx
index 0c93ec4..c9e4805 100644
--- a/frontend/src/pages/resource_details_page.tsx
+++ b/frontend/src/pages/resource_details_page.tsx
@@ -238,7 +238,8 @@ function Article({resource}: { resource: ResourceDetails }) {
return
{
+ p: ({node, ...props}) => {
+ console.log(props.children)
if (typeof props.children === "object" && (props.children as ReactElement).type === "strong") {
// @ts-ignore
const child = (props.children as ReactElement).props.children.toString() as string
@@ -250,46 +251,17 @@ function Article({resource}: { resource: ResourceDetails }) {
return !(s.startsWith("width") || s.startsWith("height") || s.startsWith("class") || s.startsWith("style"));
})
html = splits.join(" ")
- return
+ return
}
- } else if (typeof props.children === "object" && (props.children as ReactElement).type === "a") {
+ // @ts-ignore
+ } else if (typeof props.children === "object" && props.children.props && props.children.props.href) {
const a = props.children as ReactElement
const childProps = a.props as any
const href = childProps.href as string
- if (href.startsWith(window.location.origin) || href.startsWith("/")) {
- let path = href
- if (path.startsWith(window.location.origin)) {
- path = path.substring(window.location.origin.length)
- }
- const content = childProps.children?.toString()
- if (path.startsWith("/resources/")) {
- const id = path.substring("/resources/".length)
- for (const r of resource.related) {
- if (r.id.toString() === id) {
- return {
- navigate(`/resources/${r.id}`)
- }}>
- {r.image ?
-
- : null}
-
-
{r.title}
-
{content}
-
-
- }
- }
- }
- }
// @ts-ignore
if (childProps.children?.length === 2) {
// @ts-ignore
@@ -304,12 +276,12 @@ function Article({resource}: { resource: ResourceDetails }) {
return
-
- {img}
-
+
+ {img}
+
- {second}
-
+ {second}
+
}
}
@@ -328,6 +300,55 @@ function Article({resource}: { resource: ResourceDetails }) {
}
return {props.children}
},
+ a: ({node, ...props}) => {
+ const href = props.href as string
+
+ if (href.startsWith(window.location.origin) || href.startsWith("/")) {
+ let path = href
+ if (path.startsWith(window.location.origin)) {
+ path = path.substring(window.location.origin.length)
+ }
+ const content = props.children?.toString()
+ if (path.startsWith("/resources/")) {
+ const id = path.substring("/resources/".length)
+ for (const r of resource.related ?? []) {
+ if (r.id.toString() === id) {
+ return
+ {
+ navigate(`/resources/${r.id}`, {replace: true})
+ }}>
+ {r.image &&
}
+
+ {r.title}
+
+ {content}
+
+
+
+ }
+ }
+ }
+ }
+
+ return
+ },
}}>{resource.article}
}
@@ -399,7 +420,8 @@ function CloudflarePopup({file}: { file: RFile }) {
window.open(link, "_blank");
}}>
-
{t("Please check your network if the verification takes too long or the captcha does not appear.")}
+ {t("Please check your network if the verification takes too long or the captcha does not appear.")}
}