Skip to content

Commit

Permalink
Simplify page description
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Dec 29, 2024
1 parent d6352ef commit fb20835
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion www/components/index/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function PackageIndexItem(props: PackageIndexItemProps) {
<a href={`/${pkg.workspace}`}>{pkg.workspace}</a>
</h3>
<p>
{yield* pkg.MDXDescription()}
{yield* pkg.description()}
</p>
</li>
);
Expand Down
10 changes: 8 additions & 2 deletions www/hooks/use-description-parse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import remarkParse from "npm:[email protected]";
import remarkRehype from "npm:[email protected]";
import { trimAfterHR } from "../lib/trim-after-hr.ts";

export function* useDescriptionParse(markdown: string): Operation<VFile> {
export function* useDescription(markdown: string): Operation<string> {
const file = yield* useMarkdownFile(markdown);

return file.data?.meta?.description ?? "";
}

export function* useMarkdownFile(markdown: string): Operation<VFile> {
return yield* call(() =>
unified()
.use(remarkParse)
Expand All @@ -25,4 +31,4 @@ export function* useDescriptionParse(markdown: string): Operation<VFile> {
markdown,
)
);
}
}
13 changes: 5 additions & 8 deletions www/hooks/use-package.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { all, call, createContext, type Operation, type Result, Ok, Err } from "effection";
import { dirname, SEPARATOR } from "jsr:@std/[email protected]";
import type { VFile } from "npm:[email protected]";
import { SEPARATOR } from "jsr:@std/[email protected]";
import { z } from "npm:[email protected]";
import type { JSXElement } from "revolution";

import { type DocNode, useDenoDoc } from "./use-deno-doc.tsx";
import { useMDX } from "./use-mdx.tsx";
import { useDescriptionParse } from "./use-description-parse.tsx";
import { useDescription } from "./use-description-parse.tsx";
import {
PackageDetailsResult,
PackageScoreResult,
Expand Down Expand Up @@ -97,7 +96,7 @@ export interface Package {
*/
docs: Record<string, Array<RenderableDocNode>>;
MDXContent: () => Operation<JSX.Element>;
MDXDescription: () => Operation<string>;
description: () => Operation<string>;
}

export type RenderableDocNode = DocNode & {
Expand Down Expand Up @@ -294,10 +293,8 @@ export function* createPackage(config: PackageConfig) {

return mod.default({});
},
*MDXDescription(): Operation<string> {
let file: VFile = yield* useDescriptionParse(config.readme);

return file.data?.meta?.description ? file.data?.meta?.description : "";
*description(): Operation<string> {
return yield* useDescription(config.readme);
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion www/routes/package.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function packageRoute(): SitemapRoute<JSXElement> {

const AppHTML = yield* useAppHtml({
title: `${pkg.packageName}`,
description: yield* pkg.MDXDescription(),
description: yield* pkg.description(),
pageTitle: `${pkg.packageName} | Effection Contrib`,
});

Expand Down

0 comments on commit fb20835

Please sign in to comment.