Skip to content

Commit 48b5576

Browse files
committed
feat(actively): add actively pages
1 parent 834c9c0 commit 48b5576

File tree

6 files changed

+81
-4
lines changed

6 files changed

+81
-4
lines changed

src/app/(default)/r/[owner]/[repo]/post/page.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ export default function ProductPostPage(){
229229
setTopic(e.target.value)
230230
}}
231231
onKeyDown={(e) => {
232+
e.stopPropagation();
232233
if (e.key === "Enter") {
233234
if (Topic.length > 0) {
234235
setTopics([...Topics, Topic])

src/app/(default)/u/[username]/(default)/page.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {AppWrite} from "@/server/Client";
77
import {UserDashBored} from "@/server/types";
88
import {UserApi} from "@/server/UserApi";
99
import {ProductList} from "@/component/user/productlist";
10+
import {ActivelyReadme} from "@/component/user/activelyReadme";
1011

1112
export default function UserPage(props: { params: Promise<{ username: string}> }) {
1213
const api = new UserApi();
@@ -33,7 +34,7 @@ export default function UserPage(props: { params: Promise<{ username: string}> }
3334
(Loading && userDash) ? (
3435
<>
3536
<TabsPanel value="actively">
36-
actively
37+
<ActivelyReadme readme={userDash.readme}/>
3738
</TabsPanel>
3839
<TabsPanel value="repository">
3940
<UserRepoList userDash={userDash}/>

src/component/repo/repointro.tsx

+19-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,25 @@ export const RepoIntro = ({repo, owner, head}: RepoIntroProps) => {
3636
<div className="repo-intro">
3737
<div className="repo-readme">
3838
<ReactMarkdown
39-
rehypePlugins={[rehypeRaw]}>
39+
rehypePlugins={[rehypeRaw]}
40+
components={{
41+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
42+
// @ts-expect-error
43+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
44+
code: ({node, inline, className, children, ...props}) => {
45+
const match = /language-(\w+)/.exec(className || '');
46+
return !inline && match ? (
47+
<div className="code-block">
48+
<code className={className}>{children}</code>
49+
</div>
50+
) : (
51+
<code className={className} {...props}>
52+
{children}
53+
</code>
54+
);
55+
}
56+
}}
57+
>
4058
{README}
4159
</ReactMarkdown>
4260
</div>

src/component/user/activelyReadme.tsx

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import ReactMarkdown from "react-markdown";
2+
import rehypeRaw from "rehype-raw";
3+
4+
interface ActivelyReadmeProps {
5+
readme?: Uint8Array | undefined
6+
}
7+
8+
export const ActivelyReadme = ({readme}: ActivelyReadmeProps) => {
9+
if (readme) {
10+
const markdown = readme.toString();
11+
return (
12+
<div className="markdown-body">
13+
<ReactMarkdown
14+
rehypePlugins={[rehypeRaw]}
15+
components={{
16+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
17+
// @ts-expect-error
18+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
19+
code: ({node, inline, className, children, ...props}) => {
20+
const match = /language-(\w+)/.exec(className || '');
21+
return !inline && match ? (
22+
<div className="code-block">
23+
<code className={className}>{children}</code>
24+
</div>
25+
) : (
26+
<code className={className} {...props}>
27+
{children}
28+
</code>
29+
);
30+
}
31+
}}
32+
>{markdown}</ReactMarkdown>
33+
</div>
34+
)
35+
}else {
36+
return (
37+
<div className="markdown-body">
38+
<ReactMarkdown
39+
rehypePlugins={[rehypeRaw]}
40+
>{`# No README.md`}</ReactMarkdown>
41+
</div>
42+
)
43+
}
44+
}

src/style/main.css

+14-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,17 @@
77
@import "./dashbored.css";
88
@import "./usersetting.css";
99
@import "./market.css";
10-
@import "./product.css";
10+
@import "./product.css";
11+
12+
13+
.code-block {
14+
color: white;
15+
background: black;
16+
overflow-x: auto;
17+
white-space: pre;
18+
font-size: 14px;
19+
font-family: monospace;
20+
padding: 10px;
21+
margin: 10px 0;
22+
border-radius: 5px;
23+
}

src/style/repo.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
.repo-intro {
130130
display: flex;
131131
.repo-readme {
132-
width: auto;
132+
width: 100%;
133133
}
134134
.repo-intro-card {
135135
@media screen and (max-width: 1500px) {

0 commit comments

Comments
 (0)