added recent contributions to the contribution section
This commit is contained in:
parent
75192d53f1
commit
ab18ff319e
2 changed files with 60 additions and 0 deletions
9
src/app/api/activities/route.ts
Normal file
9
src/app/api/activities/route.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
export async function GET() {
|
||||||
|
try {
|
||||||
|
const res = await fetch("https://git.dvorakmortonxd.dev/api/v1/users/dvorakmortonxd/activities/feeds?limit=20");
|
||||||
|
const data = await res.json();
|
||||||
|
return Response.json(data);
|
||||||
|
} catch (e) {
|
||||||
|
return Response.json({ error: "failed to load" }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,6 +12,7 @@ export default function ContributionHeatmap() {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
const [totalContribs, setTotalContribs] = useState(0);
|
const [totalContribs, setTotalContribs] = useState(0);
|
||||||
|
const [activities, setActivities] = useState<any[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchHeatmap() {
|
async function fetchHeatmap() {
|
||||||
|
|
@ -73,7 +74,22 @@ export default function ContributionHeatmap() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchActivities() {
|
||||||
|
try {
|
||||||
|
const res = await fetch("/api/activities");
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json();
|
||||||
|
// Filter to just standard push/commit events
|
||||||
|
const valid = data.filter((d: any) => d.op_type === "commit_repo" || d.op_type === "push_repo").slice(0, 3);
|
||||||
|
setActivities(valid);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to load activities:", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fetchHeatmap();
|
fetchHeatmap();
|
||||||
|
fetchActivities();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
|
|
@ -116,6 +132,41 @@ export default function ContributionHeatmap() {
|
||||||
<div className="heatmap-legend-cell" data-level="4"></div>
|
<div className="heatmap-legend-cell" data-level="4"></div>
|
||||||
<span>More</span>
|
<span>More</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{activities.length > 0 && (
|
||||||
|
<div>
|
||||||
|
<div style={{ fontSize: "0.85rem", color: "var(--fg)", marginBottom: "4px" }}>
|
||||||
|
<span style={{ color: "var(--gray)" }}>martin@git.dvorakmortonxd.dev</span>:~$ git log -n 3 <span style={{ color: "var(--gray)" }}>#displays my 3 latest contributions</span>
|
||||||
|
</div>
|
||||||
|
{activities.map((act, idx) => {
|
||||||
|
let msg = "No message";
|
||||||
|
try {
|
||||||
|
if (act.content) {
|
||||||
|
const parsed = JSON.parse(act.content);
|
||||||
|
if (parsed.Commits && parsed.Commits.length > 0) {
|
||||||
|
msg = parsed.Commits[0].Message.split("\n")[0];
|
||||||
|
} else if (parsed.HeadCommit) {
|
||||||
|
msg = parsed.HeadCommit.Message.split("\n")[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={idx} style={{ display: "flex", flexDirection: "column", fontSize: "0.8rem", color: "var(--fg)" }}>
|
||||||
|
<div style={{ display: "flex", justifyContent: "space-between", color: "var(--green)" }}>
|
||||||
|
<span>repo: {act.repo?.full_name || "unknown"}</span>
|
||||||
|
<span style={{ color: "var(--gray)", fontSize: "0.67rem" }}>
|
||||||
|
{new Date(act.created).toLocaleDateString()}-{new Date(act.created).toLocaleTimeString()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div style={{ color: "var(--gray)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>
|
||||||
|
{msg}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue