website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
6c4290a
— pyrossh
2026-07-07T14:53:06+05:30
refactor: remove timeago, use server-side date formatting instead
- package.json +0 -1
- packages/shared/ui/src/commit-entry.tsx +1 -1
- packages/shared/ui/src/css.ts +0 -3
- packages/shared/ui/src/elements.d.ts +0 -2
- packages/shared/ui/src/issue-card.tsx +1 -1
- packages/shared/ui/src/layout.tsx +0 -1
- packages/workers/assets/src/index.ts +0 -20
- packages/workers/repos/issues/detail/src/index.tsx +3 -3
- pnpm-lock.yaml +0 -8
package.json
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"rehype-stringify": "^10.0.1",
|
|
21
21
|
"remark-parse": "^11.0.0",
|
|
22
22
|
"remark-rehype": "^11.1.2",
|
|
23
|
-
"timeago.js": "^4.0.2",
|
|
24
23
|
"typed-htmx": "^0.3.1",
|
|
25
24
|
"unified": "^11.0.5"
|
|
26
25
|
},
|
packages/shared/ui/src/commit-entry.tsx
CHANGED
|
@@ -22,7 +22,7 @@ export function CommitEntry({ repoId, commit }: CommitEntryProps) {
|
|
|
22
22
|
<small class="pull-right">
|
|
23
23
|
{commit.date && (
|
|
24
24
|
<a href={`/repos/${repoId}/logs`} rel="nofollow">
|
|
25
|
-
<
|
|
25
|
+
<span>{new Date(commit.date).toLocaleDateString("en", { year: "numeric", month: "short", day: "numeric" })}</span>
|
|
26
26
|
</a>
|
|
27
27
|
)}
|
|
28
28
|
</small>
|
packages/shared/ui/src/css.ts
CHANGED
|
@@ -991,9 +991,6 @@ footer + .safe-area {
|
|
|
991
991
|
}
|
|
992
992
|
|
|
993
993
|
/* TimeAgo */
|
|
994
|
-
time-ago {
|
|
995
|
-
display: inline;
|
|
996
|
-
}
|
|
997
994
|
|
|
998
995
|
/* File tree */
|
|
999
996
|
.file-tree {
|
packages/shared/ui/src/elements.d.ts
CHANGED
|
@@ -12,8 +12,6 @@ declare global {
|
|
|
12
12
|
|
|
13
13
|
interface IntrinsicElements {
|
|
14
14
|
summary: HtmlTag;
|
|
15
|
-
"time-ago": HtmlTag & { "data-date"?: string; date?: string };
|
|
16
|
-
"current-year": HtmlTag;
|
|
17
15
|
svg: HtmlTag & { viewBox?: string; xmlns?: string; width?: string; height?: string; fill?: string };
|
|
18
16
|
g: HtmlTag & { fill?: string; transform?: string };
|
|
19
17
|
path: HtmlTag & { d?: string; fill?: string; stroke?: string; "stroke-width"?: string; "stroke-linecap"?: string; "stroke-linejoin"?: string; opacity?: string };
|
packages/shared/ui/src/issue-card.tsx
CHANGED
|
@@ -20,7 +20,7 @@ export function IssueCard({ repoId, issue }: IssueCardProps) {
|
|
|
20
20
|
{issue.id.substring(0, 8)}
|
|
21
21
|
</a>
|
|
22
22
|
{issue.author && <span>by {issue.author}</span>}
|
|
23
|
-
{date && <
|
|
23
|
+
{date && <span>{new Date(date).toLocaleDateString("en", { year: "numeric", month: "short", day: "numeric" })}</span>}
|
|
24
24
|
{issue.comments.length > 0 && <span>{issue.comments.length} comments</span>}
|
|
25
25
|
</div>
|
|
26
26
|
{issue.labels.length > 0 && (
|
packages/shared/ui/src/layout.tsx
CHANGED
|
@@ -40,7 +40,6 @@ export function Layout({ title, description, request, children }: LayoutProps) {
|
|
|
40
40
|
<meta property="twitter:image" content="/assets/icons/icon.svg" />
|
|
41
41
|
<style>{globalCSS}</style>
|
|
42
42
|
<script src="https://unpkg.com/[email protected]"></script>
|
|
43
|
-
<script src="/assets/js/timeago.js"></script>
|
|
44
43
|
</head>
|
|
45
44
|
<body>
|
|
46
45
|
<Header currentPath={url?.pathname} />
|
packages/workers/assets/src/index.ts
CHANGED
|
@@ -2,26 +2,6 @@ export default {
|
|
|
2
2
|
async fetch(request: Request, env: any): Promise<Response> {
|
|
3
3
|
const url = new URL(request.url);
|
|
4
4
|
|
|
5
|
-
if (url.pathname === "/assets/js/timeago.js") {
|
|
6
|
-
return new Response(`class TimeAgo extends HTMLElement {
|
|
7
|
-
connectedCallback() {
|
|
8
|
-
const d = new Date(this.getAttribute("date") || this.getAttribute("data-date"));
|
|
9
|
-
if (isNaN(d.getTime())) return;
|
|
10
|
-
const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
11
|
-
const diff = d.getTime() - Date.now();
|
|
12
|
-
for (const [ms, u] of [[864e5,"day"],[36e5,"hour"],[6e4,"minute"],[1e3,"second"]]) {
|
|
13
|
-
if (Math.abs(diff) >= ms) { this.textContent = rtf.format(Math.round(diff/ms), u); break; }
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
customElements.define("time-ago", TimeAgo);
|
|
18
|
-
class CurrentYear extends HTMLElement {
|
|
19
|
-
connectedCallback() { this.textContent = String(new Date().getFullYear()); }
|
|
20
|
-
}
|
|
21
|
-
customElements.define("current-year", CurrentYear);
|
|
22
|
-
`, { headers: { "content-type": "application/javascript" } });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
5
|
return new Response("Not found", { status: 404 });
|
|
26
6
|
},
|
|
27
7
|
};
|
packages/workers/repos/issues/detail/src/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { RepoLayout } from "@pyrossh/ui";
|
|
|
2
2
|
import { getRepo, getGitBugIssue, addGitBugIssueComment, setGitBugIssueState } from "@pyrossh/core";
|
|
3
3
|
import type { Env, GitBugIssue } from "@pyrossh/types";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const fmtDate = (date: string) => new Date(date).toLocaleDateString("en", { year: "numeric", month: "short", day: "numeric" });
|
|
6
6
|
|
|
7
7
|
const StateBadge = (issue: GitBugIssue) => (
|
|
8
8
|
<span id="state-badge" class={`state ${issue.state}`}>
|
|
@@ -19,7 +19,7 @@ const CommentsSection = (repoId: string, issue: GitBugIssue) => (
|
|
|
19
19
|
<article class="comment">
|
|
20
20
|
<div class="comment-meta">
|
|
21
21
|
{comment.author && <strong>{comment.author}</strong>}
|
|
22
|
-
{comment.createdAt &&
|
|
22
|
+
{comment.createdAt && <span>{fmtDate(comment.createdAt)}</span>}
|
|
23
23
|
</div>
|
|
24
24
|
<pre>{comment.body}</pre>
|
|
25
25
|
</article>
|
|
@@ -56,7 +56,7 @@ const IssueHeader = (repoId: string, issue: GitBugIssue) => (
|
|
|
56
56
|
{issue.id.substring(0, 8)}
|
|
57
57
|
</a>
|
|
58
58
|
{issue.author && <span>by {issue.author}</span>}
|
|
59
|
-
{issue.createdAt &&
|
|
59
|
+
{issue.createdAt && <span>{fmtDate(issue.createdAt)}</span>}
|
|
60
60
|
{issue.comments.length > 0 && <span>{issue.comments.length} comments</span>}
|
|
61
61
|
</div>
|
|
62
62
|
{issue.labels.length > 0 && (
|
pnpm-lock.yaml
CHANGED
|
@@ -237,9 +237,6 @@ importers:
|
|
|
237
237
|
remark-rehype:
|
|
238
238
|
specifier: ^11.1.2
|
|
239
239
|
version: 11.1.2
|
|
240
|
-
timeago.js:
|
|
241
|
-
specifier: ^4.0.2
|
|
242
|
-
version: 4.0.2
|
|
243
240
|
typed-htmx:
|
|
244
241
|
specifier: ^0.3.1
|
|
245
242
|
version: 0.3.1
|
|
@@ -2313,9 +2310,6 @@ packages:
|
|
|
2313
2310
|
resolution: {integrity: sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==}
|
|
2314
2311
|
engines: {node: '>=18'}
|
|
2315
2312
|
|
|
2316
|
|
|
2317
|
-
resolution: {integrity: sha512-a7wPxPdVlQL7lqvitHGGRsofhdwtkoSXPGATFuSOA2i1ZNQEPLrGnj68vOp2sOJTCFAQVXPeNMX/GctBaO9L2w==}
|
|
2318
|
-
|
|
2319
2313
|
|
|
2320
2314
|
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
|
|
2321
2315
|
|
|
@@ -4010,8 +4004,6 @@ snapshots:
|
|
|
4010
4004
|
|
|
4011
4005
|
|
|
4012
4006
|
|
|
4013
|
-
[email protected]: {}
|
|
4014
|
-
|
|
4015
4007
|
|
|
4016
4008
|
|
|
4017
4009
|