Skip to content

Commit

Permalink
add sort of changelogs, fix binding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vorant94 committed May 6, 2024
1 parent 19e274b commit adca982
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions packages/blog/src/projects/utils/changelog.query.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { compareDesc } from 'date-fns';
import path from 'node:path';
import type { VFile } from 'vfile';
import {
Expand All @@ -13,7 +14,7 @@ import {
export async function queryAllChangelogs(): Promise<ChangelogModel[]> {
const projectFilePaths = await readContentDir(`projects/*/changelogs`);

return await Promise.all(
const changelogs = await Promise.all(
projectFilePaths.map(async (filePath) => {
const rawFile = await readContentFile(filePath);

Expand All @@ -22,6 +23,10 @@ export async function queryAllChangelogs(): Promise<ChangelogModel[]> {
return changelogSchema.parse(processedFile.data);
}),
);

return changelogs.toSorted((a, b) =>
compareDesc(a.matter.publishedAt, b.matter.publishedAt),
);
}

export async function queryChangelogsByProject(
Expand All @@ -31,7 +36,7 @@ export async function queryChangelogsByProject(
`projects/${projectId}/changelogs`,
);

return await Promise.all(
const changelogs = await Promise.all(
projectFilePaths.map(async (filePath) => {
const rawFile = await readContentFile(filePath);

Expand All @@ -40,6 +45,10 @@ export async function queryChangelogsByProject(
return changelogSchema.parse(processedFile.data);
}),
);

return changelogs.toSorted((a, b) =>
compareDesc(a.matter.publishedAt, b.matter.publishedAt),
);
}

export async function queryChangelog(
Expand Down
2 changes: 1 addition & 1 deletion packages/blog/src/ui/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Link: FC<PropsWithChildren<LinkProps>> = function ({
<a
x-data={`{href: '${href}'}`}
x-on:mouseenter={`$store.prefetchedLinks.prefetchLink("${href && isInternalUrl(href) ? href : ''}")`}
x-bind:class={bindClass || false}
x-bind:class={bindClass ? bindClass : undefined}
className={cn(
'text-slate-500 decoration-cyan-500 decoration-dotted decoration-4 underline-offset-4 hover:text-cyan-500 hover:underline group-hover:text-cyan-500 group-hover:underline',
linkSizeToStyles[size],
Expand Down

0 comments on commit adca982

Please sign in to comment.