~repos /website

#astro#js#html#css

git clone https://pyrossh.dev/repos/website.git

木 Personal website of pyrossh. Built with astrojs, shiki, vite.


9ec4783f pyrossh

3 weeks ago
update commit diff
bun.lock CHANGED
@@ -25,6 +25,7 @@
25
25
  "@playwright/test": "^1.52.0",
26
26
  "@tauri-apps/cli": "^2.9.1",
27
27
  "@types/bun": "^1.3.2",
28
+ "diff2html": "^3.4.52",
28
29
  },
29
30
  },
30
31
  },
@@ -547,6 +548,8 @@
547
548
 
548
549
  "@ungap/structured-clone": ["@ungap/structured-clone@1.3.0", "", {}, "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g=="],
549
550
 
551
+ "abbrev": ["abbrev@1.1.1", "", {}, "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="],
552
+
550
553
  "acorn": ["acorn@8.14.1", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg=="],
551
554
 
552
555
  "acorn-walk": ["acorn-walk@8.3.2", "", {}, "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A=="],
@@ -719,7 +722,9 @@
719
722
 
720
723
  "dfa": ["dfa@1.2.0", "", {}, "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q=="],
721
724
 
722
- "diff": ["diff@5.2.0", "", {}, "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A=="],
725
+ "diff": ["diff@7.0.0", "", {}, "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw=="],
726
+
727
+ "diff2html": ["diff2html@3.4.52", "", { "dependencies": { "diff": "^7.0.0", "hogan.js": "3.0.2" }, "optionalDependencies": { "highlight.js": "11.9.0" } }, "sha512-qhMg8/I3sZ4zm/6R/Kh0xd6qG6Vm86w6M+C9W+DuH1V8ACz+1cgEC8/k0ucjv6AGqZWzHm/8G1gh7IlrUqCMhg=="],
723
728
 
724
729
  "direction": ["direction@2.0.1", "", { "bin": { "direction": "cli.js" } }, "sha512-9S6m9Sukh1cZNknO1CWAr2QAWsbKLafQiyM5gZ7VgXHeuaoUwffKN4q6NC4A/Mf9iiPlOXQEKW/Mv/mh9/3YFA=="],
725
730
 
@@ -873,6 +878,10 @@
873
878
 
874
879
  "hastscript": ["hastscript@9.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-parse-selector": "^4.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0" } }, "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w=="],
875
880
 
881
+ "highlight.js": ["highlight.js@11.9.0", "", {}, "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw=="],
882
+
883
+ "hogan.js": ["hogan.js@3.0.2", "", { "dependencies": { "mkdirp": "0.3.0", "nopt": "1.0.10" }, "bin": { "hulk": "./bin/hulk" } }, "sha512-RqGs4wavGYJWE07t35JQccByczmNUXQT0E12ZYV1VKYu5UiAU9lsos/yBAcf840+zrUQQxgVduCR5/B8nNtibg=="],
884
+
876
885
  "html-escaper": ["html-escaper@3.0.3", "", {}, "sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ=="],
877
886
 
878
887
  "html-void-elements": ["html-void-elements@3.0.0", "", {}, "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg=="],
@@ -1043,7 +1052,7 @@
1043
1052
 
1044
1053
  "minizlib": ["minizlib@2.1.2", "", { "dependencies": { "minipass": "^3.0.0", "yallist": "^4.0.0" } }, "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg=="],
1045
1054
 
1046
- "mkdirp": ["mkdirp@1.0.4", "", { "bin": { "mkdirp": "bin/cmd.js" } }, "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="],
1055
+ "mkdirp": ["mkdirp@0.3.0", "", {}, "sha512-OHsdUcVAQ6pOtg5JYWpCBo9W/GySVuwvP9hueRMW7UqshC0tbfzLv8wjySTPm3tfUZ/21CE9E1pJagOA91Pxew=="],
1047
1056
 
1048
1057
  "mlly": ["mlly@1.8.0", "", { "dependencies": { "acorn": "^8.15.0", "pathe": "^2.0.3", "pkg-types": "^1.3.1", "ufo": "^1.6.1" } }, "sha512-l8D9ODSRWLe2KHJSifWGwBqpTZXIXTeo8mlKjY+E2HAakaTeNpqAyBZ8GSqLzHgw4XmHmC8whvpjJNMbFZN7/g=="],
1049
1058
 
@@ -1065,6 +1074,8 @@
1065
1074
 
1066
1075
  "node-mock-http": ["node-mock-http@1.0.0", "", {}, "sha512-0uGYQ1WQL1M5kKvGRXWQ3uZCHtLTO8hln3oBjIusM75WoesZ909uQJs/Hb946i2SS+Gsrhkaa6iAO17jRIv6DQ=="],
1067
1076
 
1077
+ "nopt": ["nopt@1.0.10", "", { "dependencies": { "abbrev": "1" }, "bin": { "nopt": "./bin/nopt.js" } }, "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg=="],
1078
+
1068
1079
  "normalize-path": ["normalize-path@3.0.0", "", {}, "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="],
1069
1080
 
1070
1081
  "npm-run-path": ["npm-run-path@6.0.0", "", { "dependencies": { "path-key": "^4.0.0", "unicorn-magic": "^0.3.0" } }, "sha512-9qny7Z9DsQU8Ou39ERsPU4OZQlSTP47ShQzuKZ6PRXpYLtIFgl/DEBYEXKlvcEa+9tHVcK8CF81Y2V72qaZhWA=="],
@@ -1435,6 +1446,8 @@
1435
1446
 
1436
1447
  "anymatch/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
1437
1448
 
1449
+ "astro/diff": ["diff@5.2.0", "", {}, "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A=="],
1450
+
1438
1451
  "boxen/chalk": ["chalk@5.4.1", "", {}, "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w=="],
1439
1452
 
1440
1453
  "cheerio/undici": ["undici@6.21.3", "", {}, "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw=="],
@@ -1483,6 +1496,8 @@
1483
1496
 
1484
1497
  "tar/minipass": ["minipass@5.0.0", "", {}, "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ=="],
1485
1498
 
1499
+ "tar/mkdirp": ["mkdirp@1.0.4", "", { "bin": { "mkdirp": "bin/cmd.js" } }, "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="],
1500
+
1486
1501
  "unicode-trie/pako": ["pako@0.2.9", "", {}, "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA=="],
1487
1502
 
1488
1503
  "vite/fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
package.json CHANGED
@@ -32,12 +32,13 @@
32
32
  "timeago.js": "^4.0.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@aws-sdk/client-sts": "^3.932.0",
36
35
  "@aws-sdk/client-s3": "^3.932.0",
37
- "@iconify-json/mdi": "^1.2.3",
36
+ "@aws-sdk/client-sts": "^3.932.0",
38
37
  "@iconify-json/material-symbols": "^1.2.39",
38
+ "@iconify-json/mdi": "^1.2.3",
39
39
  "@playwright/test": "^1.52.0",
40
40
  "@tauri-apps/cli": "^2.9.1",
41
- "@types/bun": "^1.3.2"
41
+ "@types/bun": "^1.3.2",
42
+ "diff2html": "^3.4.52"
42
43
  }
43
44
  }
src/content.config.ts CHANGED
@@ -24,7 +24,6 @@ export const collections = {
24
24
  const readmePath = repoPath + "/README.md";
25
25
  console.log("loading repo " + repoPath)
26
26
  const git = simpleGit(repoPath)
27
- // "-p",
28
27
  const commits = await git.log(["--branches", "--tags"]);
29
28
  const paths = await git.raw(["ls-files"]);
30
29
  const files = [];
@@ -32,7 +31,7 @@ export const collections = {
32
31
  try {
33
32
  const stat = await fs.stat(`${repoPath}/${p}`);
34
33
  const isLarge = stat.size > 1024 * 512;
35
- const history = isLarge ? { all: [] } : await git.log(["-p", p]);
34
+ const history = isLarge ? { all: [] } : await git.log([p]);
36
35
  files.push({
37
36
  name: p,
38
37
  absolutePath: `${repoPath}/${p}`,
@@ -58,6 +57,7 @@ export const collections = {
58
57
  badges: r.badges || [],
59
58
  commits: commits.all.map(collectCommits),
60
59
  files: fileTree,
60
+ absolutePath: repoPath,
61
61
  },
62
62
  rendered: readmeContent,
63
63
  });
@@ -75,6 +75,7 @@ export const collections = {
75
75
  })).optional(),
76
76
  commits: z.array(CommitSchema),
77
77
  files: z.array(FileNodeSchema),
78
+ absolutePath: z.string(),
78
79
  }),
79
80
  }),
80
81
  content: defineCollection({
src/pages/repos/[...repoId]/commits/[...hash]/index.astro CHANGED
@@ -3,6 +3,8 @@ import { type CollectionEntry, getCollection } from "astro:content";
3
3
  import RepoLayout from "@/layouts/RepoLayout.astro";
4
4
  import Commit from "@/components/Commit.astro";
5
5
  import type { Commit as CommitType } from "../../../../../utils/files";
6
+ import { generateHTMLDiff } from "@/utils/diff";
7
+ import "diff2html/bundles/css/diff2html.min.css";
6
8
 
7
9
  export async function getStaticPaths() {
8
10
  const repos = await getCollection("repos");
@@ -23,9 +25,10 @@ type Props = {
23
25
  };
24
26
 
25
27
  const { repo, commit } = Astro.props;
28
+ const diffHtml = await generateHTMLDiff(repo.data.absolutePath, commit.hash);
26
29
  ---
27
30
 
28
31
  <RepoLayout repo={repo}>
29
32
  <Commit repoId={repo.id} commit={commit} />
30
- <p>WIP: Show Diff summary</p>
33
+ <div set:html={diffHtml} />
31
34
  </RepoLayout>
src/utils/diff.ts ADDED
@@ -0,0 +1,13 @@
1
+ import Diff2html from "diff2html";
2
+ import { simpleGit } from "simple-git";
3
+
4
+ export const generateHTMLDiff = async (repoPath: string, hash: string, file?: string): Promise<string> => {
5
+ const git = simpleGit(repoPath);
6
+ const diff = await git.diff([`${hash}^..${hash}`].concat(file ? [file] : []));
7
+ const diffJson = Diff2html.parse(diff);
8
+ const diffHtml = Diff2html.html(diffJson, {
9
+ drawFileList: true,
10
+ matching: "lines",
11
+ });
12
+ return diffHtml;
13
+ }
src/utils/files.ts CHANGED
@@ -16,7 +16,6 @@ export interface Commit {
16
16
  date: string;
17
17
  branches: string[];
18
18
  tags: string[];
19
- diff?: string;
20
19
  }
21
20
 
22
21
  export interface FileNode {
@@ -39,7 +38,6 @@ export const CommitSchema = z.object({
39
38
  date: z.string(),
40
39
  branches: z.array(z.string()),
41
40
  tags: z.array(z.string()),
42
- diff: z.string().optional(),
43
41
  });
44
42
 
45
43
  export const FileNodeSchema: z.ZodType<FileNode> = z.lazy(() =>