Skip to content

Commit bddd1e4

Browse files
chore: code adjustments
1 parent 8cd6448 commit bddd1e4

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/lib/components/MarkdownRenderer.svelte

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
* @component
77
*/
8+
import type { ComponentProps } from "svelte";
89
import type { ClassValue } from "svelte/elements";
910
import Markdown, { type Plugin } from "svelte-exmarkdown";
1011
import { gfmPlugin } from "svelte-exmarkdown/gfm";
@@ -13,20 +14,23 @@
1314
import { cn } from "$lib/utils";
1415
import { Button } from "$lib/components/ui/button";
1516
17+
type MdSnippets = Omit<ComponentProps<typeof Markdown>, "md" | "plugins">;
18+
1619
type Props = {
1720
markdown: string;
1821
inline?: boolean;
1922
parseRawHtml?: boolean;
2023
additionalPlugins?: Plugin[];
2124
class?: ClassValue;
22-
};
25+
} & MdSnippets;
2326
2427
let {
2528
markdown: md,
2629
inline = false,
2730
parseRawHtml = false,
2831
additionalPlugins = [],
29-
class: className = undefined
32+
class: className = undefined,
33+
...snippets
3034
}: Props = $props();
3135
</script>
3236

@@ -68,7 +72,7 @@
6872
</Button>
6973
</div>
7074
{/if}
71-
<Markdown {md} />
75+
<Markdown {md} {...snippets} />
7276
{/snippet}
7377

7478
<Markdown
@@ -78,6 +82,7 @@
7882
...(parseRawHtml ? [{ rehypePlugin: rehypeRaw }] : []),
7983
...additionalPlugins
8084
]}
85+
{...snippets}
8186
/>
8287
</svelte:boundary>
8388
</svelte:element>

src/lib/server/github-cache.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class GitHubCache {
117117

118118
/**
119119
* Get the item (issue or pr) with the given information.
120-
* Return the appropriate value if the type is defined, or
120+
* Return the appropriate value if the type is defined or
121121
* try to coerce it otherwise.
122122
*
123123
* @param owner the GitHub repository owner
@@ -512,13 +512,15 @@ export class GitHubCache {
512512
* Irrelevant paths (e.g., tests) or empty descriptions
513513
* are excluded.
514514
*
515-
* @param repository the repository to fetch the
515+
* @param owner the GitHub repository owner to fetch the
516+
* descriptions in
517+
* @param repo the GitHub repository name to fetch the
516518
* descriptions in
517519
* @returns a map of paths to descriptions.
518520
* @private
519521
*/
520-
async getDescriptions(repository: Repository) {
521-
const cacheKey = this.#getRepoKey(repository.owner, repository.repoName, "descriptions");
522+
async getDescriptions(owner: string, repo: string) {
523+
const cacheKey = this.#getRepoKey(owner, repo, "descriptions");
522524

523525
const cachedDescriptions = await this.#redis.json.get<{ [key: string]: string }>(cacheKey);
524526
if (cachedDescriptions) {
@@ -528,8 +530,6 @@ export class GitHubCache {
528530

529531
console.log(`Cache miss for releases for ${cacheKey}, fetching from GitHub API`);
530532

531-
const { owner, repoName: repo } = repository;
532-
533533
const { data: allFiles } = await this.#octokit.rest.git.getTree({
534534
owner,
535535
repo,

src/lib/server/package-discoverer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class PackageDiscoverer {
3838
this.#packages = await Promise.all(
3939
this.#repos.map(async repo => {
4040
const releases = await this.#cache.getReleases(repo);
41-
const descriptions = await this.#cache.getDescriptions(repo);
41+
const descriptions = await this.#cache.getDescriptions(repo.owner, repo.repoName);
4242
const packages = [
4343
...new Set(
4444
releases

src/routes/package/[...package]/ReleaseCard.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@
7878
const formatter = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
7979
8080
if (years > 0) {
81-
return formatter.format(0 - years, "year");
81+
return formatter.format(-years, "year");
8282
} else if (months > 0) {
83-
return formatter.format(0 - months, "month");
83+
return formatter.format(-months, "month");
8484
} else if (days > 0) {
85-
return formatter.format(0 - days, "day");
85+
return formatter.format(-days, "day");
8686
} else if (hours > 0) {
87-
return formatter.format(0 - hours, "hour");
87+
return formatter.format(-hours, "hour");
8888
} else if (minutes > 0) {
89-
return formatter.format(0 - minutes, "minute");
89+
return formatter.format(-minutes, "minute");
9090
}
91-
return formatter.format(0 - diff, "second");
91+
return formatter.format(-diff, "second");
9292
}
9393
9494
type Reaction = Exclude<keyof NonNullable<(typeof release)["reactions"]>, "url" | "total_count">;

0 commit comments

Comments
 (0)