Skip to content

Commit dd9a13e

Browse files
committed
feat: update components to use new handle package data
1 parent d755bab commit dd9a13e

File tree

8 files changed

+61
-45
lines changed

8 files changed

+61
-45
lines changed

codebook.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ words = [
88
"cloudflarestorage",
99
"cwd",
1010
"dompurify",
11+
"dvh",
1112
"fflate",
1213
"gitlab",
1314
"iconify",
@@ -23,6 +24,7 @@ words = [
2324
"runed",
2425
"shiki",
2526
"svh",
27+
"unpkg",
2628
"unplugin",
2729
"vercel",
2830
"vite",

src/components/PackageAbout.astro

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
import newGitHubIssueURL from "new-github-issue-url";
3-
import type { PackagePageHandlerProps } from "../../lib/package-page-handler";
43
import AnchoredH2 from "./AnchoredH2.astro";
4+
import type { HandlePackageData } from "../../lib/handlers/package/handle-package";
55
6-
type Props = PackagePageHandlerProps;
6+
type Props = HandlePackageData;
77
8-
const { status, pkgId, generatedAt, generatedIn } = Astro.props;
8+
const { status, pkgInfo } = Astro.props;
9+
const { pkgId, generatedAt, generatedIn } = pkgInfo;
910
const issueUrl = newGitHubIssueURL({
1011
repoUrl: "https://github.com/jsdocs-io/web",
1112
template: "package-with-missing-or-incorrect-documentation.md",
@@ -23,17 +24,17 @@ const issueUrl = newGitHubIssueURL({
2324
datetime={generatedAt}></time> in {generatedIn}ms.
2425

2526
{
26-
status === "with-api" && (
27+
status === "pkg-has-api" && (
2728
<>
2829
<br />
2930
Package <code class="text-nowrap">{pkgId}</code> analyzed{" "}
3031
<time
31-
x-data={`timeAgo('${Astro.props.pkgApi.analyzedAt}')`}
32+
x-data={`timeAgo('${pkgInfo.pkgApi.analyzedAt}')`}
3233
x-text="text"
33-
title={Astro.props.pkgApi.analyzedAt}
34-
datetime={Astro.props.pkgApi.analyzedAt}
34+
title={pkgInfo.pkgApi.analyzedAt}
35+
datetime={pkgInfo.pkgApi.analyzedAt}
3536
/>{" "}
36-
in {Astro.props.pkgApi.analyzedIn}ms.
37+
in {pkgInfo.pkgApi.analyzedIn}ms.
3738
</>
3839
)
3940
}

src/components/PackageApi.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
import { makeDeclarationUrl } from "../../lib/declaration-url";
3-
import type { PackagePageHandlerProps } from "../../lib/package-page-handler";
3+
import type { PackageInfoWithApi } from "../../lib/handlers/package/handle-package";
44
import { makeUnpkgUrl } from "../../lib/unpkg-url";
55
import Declarations from "./Declarations.astro";
66
7-
type Props = PackagePageHandlerProps & { status: "with-api" };
7+
type Props = PackageInfoWithApi;
88
99
const {
10-
pkgApi: { declarations, packages },
10+
pkgApi: { declarations, dependencies },
1111
} = Astro.props;
12-
const unpkgUrl = makeUnpkgUrl(packages);
12+
const unpkgUrl = makeUnpkgUrl(dependencies);
1313
const declarationUrl = makeDeclarationUrl(declarations);
1414
---
1515

src/components/PackageOverview.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
import type { PackagePageHandlerProps } from "../../lib/package-page-handler";
2+
import type { HandlePackageData } from "../../lib/handlers/package/handle-package";
33
import AnchoredH2 from "./AnchoredH2.astro";
44
import DocComment from "./DocComment.astro";
55
6-
type Props = PackagePageHandlerProps;
6+
type Props = HandlePackageData;
77
8-
const { status, pkgJson } = Astro.props;
8+
const { status, pkgInfo } = Astro.props;
99
const overview =
10-
status === "with-api" && Astro.props.pkgApi.overview ? Astro.props.pkgApi.overview
11-
: pkgJson.description ? `/** ${pkgJson.description} */`
10+
status === "pkg-has-api" && pkgInfo.pkgApi.overview ? pkgInfo.pkgApi.overview
11+
: pkgInfo.pkgJson.description ? `/** ${pkgInfo.pkgJson.description} */`
1212
: `/** Overview not available. */`;
1313
---
1414

src/components/PackagePageAlerts.astro

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,70 @@
22
import LucideCircleX from "~icons/lucide/circle-x";
33
import LucidePackageCheck from "~icons/lucide/package-check";
44
import LucideTriangleAlert from "~icons/lucide/triangle-alert";
5-
import type { PackagePageHandlerProps } from "../../lib/package-page-handler";
5+
import type { HandlePackageData } from "../../lib/handlers/package/handle-package";
66
7-
type Props = PackagePageHandlerProps;
7+
type Props = HandlePackageData;
88
9-
const { status, pkgId } = Astro.props;
9+
const { status, pkgInfo } = Astro.props;
1010
---
1111

1212
{
13-
["invalid-license", "no-types", "definitely-typed", "no-api"].includes(status) && (
13+
status !== "pkg-has-api" && (
1414
<div role="alert" class="alert col-span-full justify-self-center text-balance lg:w-fit">
15-
{status === "invalid-license" && (
15+
{status === "pkg-has-invalid-license" && (
1616
<>
1717
<LucideTriangleAlert class="size-6" />
1818
<span>
19-
Documentation is unavailable because package {pkgId} is unlicensed or has a proprietary
20-
license.
19+
Documentation is unavailable because package {pkgInfo.pkgId} is unlicensed or has a
20+
proprietary license.
2121
</span>
2222
</>
2323
)}
2424

25-
{status === "no-types" && (
25+
{status === "pkg-has-no-types" && (
2626
<>
2727
<LucideTriangleAlert class="size-6" />
2828
<span>
29-
Documentation is unavailable because package {pkgId} doesn't export type definitions.
29+
Documentation is unavailable because package {pkgInfo.pkgId} doesn't export type
30+
definitions.
3031
</span>
3132
</>
3233
)}
3334

34-
{status === "definitely-typed" && (
35+
{status === "pkg-is-deprecated-dt-pkg" && (
36+
<>
37+
<LucideTriangleAlert class="size-6" />
38+
<span>
39+
Documentation is unavailable because package {pkgInfo.pkgId} is a deprecated Definitely
40+
Typed package.
41+
</span>
42+
</>
43+
)}
44+
45+
{status === "pkg-has-dt-pkg" && (
3546
<>
3647
<LucidePackageCheck class="size-6" />
3748
<span>
38-
Type definitions for {pkgId} are available in the{" "}
39-
<a class="link-hover link font-bold" href={`/package/${Astro.props.dtPkgName}`}>
40-
{Astro.props.dtPkgName}
49+
Type definitions for {pkgInfo.pkgId} are available in the{" "}
50+
<a class="link-hover link font-bold" href={`/package/${pkgInfo.dtPkgName}`}>
51+
{pkgInfo.dtPkgName}
4152
</a>{" "}
4253
package.
4354
</span>
4455
<a
45-
href={`/package/${Astro.props.dtPkgName}`}
56+
href={`/package/${pkgInfo.dtPkgName}`}
4657
class="btn btn-outline btn-sm border-base-content/50"
4758
>
4859
See documentation
4960
</a>
5061
</>
5162
)}
5263

53-
{status === "no-api" && (
64+
{status === "pkg-has-no-api" && (
5465
<>
5566
<LucideCircleX class="size-6" />
5667
<span>
57-
Documentation is unavailable because API extraction failed for package {pkgId}.
68+
Documentation is unavailable because API extraction failed for package {pkgInfo.pkgId}.
5869
</span>
5970
</>
6071
)}

src/components/PackagePageArticle.astro

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import type { PackagePageHandlerProps } from "../../lib/package-page-handler";
2+
import type { HandlePackageData } from "../../lib/handlers/package/handle-package";
33
import PackageAbout from "./PackageAbout.astro";
44
import PackageApi from "./PackageApi.astro";
55
import PackageBadge from "./PackageBadge.astro";
@@ -8,17 +8,18 @@ import PackageInfoBadges from "./PackageInfoBadges.astro";
88
import PackageOverview from "./PackageOverview.astro";
99
import PackageTitle from "./PackageTitle.astro";
1010
11-
type Props = PackagePageHandlerProps;
11+
type Props = HandlePackageData;
1212
13-
const { status, pkgJson } = Astro.props;
13+
const { status, pkgInfo } = Astro.props;
14+
const { pkgJson } = pkgInfo;
1415
---
1516

1617
<main id="main-content">
17-
<article class="prose max-w-[100ch] break-words">
18+
<article class="prose max-w-[100ch] wrap-break-word">
1819
<PackageTitle {pkgJson} />
1920
<PackageInfoBadges {pkgJson} />
2021
<PackageOverview {...Astro.props} />
21-
{status === "with-api" && <PackageApi {...Astro.props} />}
22+
{status === "pkg-has-api" && <PackageApi {...pkgInfo} />}
2223
<PackageDependencies {pkgJson} />
2324
<PackageBadge name={pkgJson.name} />
2425
<PackageAbout {...Astro.props} />

src/components/PackagePageIndex.astro

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
2-
import type { PackagePageHandlerProps } from "../../lib/package-page-handler";
2+
import type { HandlePackageData } from "../../lib/handlers/package/handle-package";
33
import PackagePageIndexDeclarations from "./PackagePageIndexDeclarations.astro";
44
5-
type Props = PackagePageHandlerProps;
5+
type Props = HandlePackageData;
66
7-
const { status, pkgJson } = Astro.props;
7+
const { status, pkgInfo } = Astro.props;
8+
const { pkgJson } = pkgInfo;
89
const hasPeerDeps = Object.keys(pkgJson.peerDependencies ?? {}).length > 0;
910
---
1011

@@ -14,10 +15,10 @@ const hasPeerDeps = Object.keys(pkgJson.peerDependencies ?? {}).length > 0;
1415

1516
{/* Declarations. */}
1617
{
17-
status === "with-api" && (
18+
status === "pkg-has-api" && (
1819
<PackagePageIndexDeclarations
1920
containerName="package"
20-
declarations={Astro.props.pkgApi.declarations}
21+
declarations={pkgInfo.pkgApi.declarations}
2122
/>
2223
)
2324
}

src/components/PackagePageSidebar.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
import type { PackagePageHandlerProps } from "../../lib/package-page-handler";
2+
import type { HandlePackageData } from "../../lib/handlers/package/handle-package";
33
import PackagePageIndex from "./PackagePageIndex.astro";
44
import QuickSearchOpener from "./QuickSearchOpener.astro";
55
6-
type Props = PackagePageHandlerProps;
6+
type Props = HandlePackageData;
77
---
88

99
{/* Make sidebar sticky on scroll and center it with 1.5rem above and below when full height. */}

0 commit comments

Comments
 (0)