Skip to content

Commit

Permalink
파트너정산 릴리즈노트 섹션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
XiNiHa committed May 16, 2024
1 parent 4dbf41c commit 76ce98f
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 9 deletions.
Empty file.
33 changes: 32 additions & 1 deletion src/layouts/release-notes/Nav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import type { ReleaseNote } from "~/misc/releaseNote";
interface Props {
consoleNotes: ReleaseNote[];
apiSdkNotes: ReleaseNote[];
platformNotes: ReleaseNote[];
activeSlug?: string;
}
const { consoleNotes, apiSdkNotes, activeSlug } = Astro.props;
const { consoleNotes, apiSdkNotes, platformNotes, activeSlug } = Astro.props;
---

<nav>
Expand Down Expand Up @@ -72,5 +73,35 @@ const { consoleNotes, apiSdkNotes, activeSlug } = Astro.props;
}
</ul>
</li>
{
platformNotes.length > 0 && (
<li class="mb-4">
<h4 class="p-2 text-lg font-bold first:mt-0">파트너 정산 자동화</h4>
<ul class="flex flex-col gap-1">
{platformNotes.map((note) => {
const title = `${format(
note.entry.data.releasedAt,
"yyyy-MM-dd",
)} 업데이트`;
const isActive = note.slug === activeSlug;
const href = `/release-notes/${note.slug}`;
return (
<li>
<JustLink
title={title}
href={href}
isActive={isActive}
event={{
name: "Developers_Releasenote_Menu_Click",
props: { slug: note.slug },
}}
/>
</li>
);
})}
</ul>
</li>
)
}
</ul>
</nav>
9 changes: 6 additions & 3 deletions src/misc/releaseNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ export async function getReleaseNotes() {
const docEntries = await getCollection("release-notes");
const apiSdkNotes: ReleaseNote[] = [];
const consoleNotes: ReleaseNote[] = [];
const platformNotes: ReleaseNote[] = [];
for (const entry of docEntries) {
const slug = entry.slug;
if (slug.startsWith("api-sdk")) apiSdkNotes.push({ slug, entry });
else if (slug.startsWith("console")) consoleNotes.push({ slug, entry });
else if (slug.startsWith("platform")) platformNotes.push({ slug, entry });
}
apiSdkNotes.sort((a, b) => (a.slug > b.slug ? -1 : 1));
consoleNotes.sort((a, b) => (a.slug > b.slug ? -1 : 1));
return { apiSdkNotes, consoleNotes };
for (const notes of [apiSdkNotes, consoleNotes, platformNotes]) {
notes.sort((a, b) => (a.slug > b.slug ? -1 : 1));
}
return { apiSdkNotes, consoleNotes, platformNotes };
}
25 changes: 22 additions & 3 deletions src/pages/release-notes/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import { format } from "date-fns";
import { match } from "ts-pattern";
import * as prose from "~/components/prose";
import Banner from "~/components/release-note/Banner.astro";
Expand All @@ -10,17 +11,34 @@ import { getReleaseNotes } from "~/misc/releaseNote";
const { slug } = Astro.params;
if (!slug) return new Response(null, { status: 404 });
const { apiSdkNotes, consoleNotes } = await getReleaseNotes();
const { apiSdkNotes, consoleNotes, platformNotes } = await getReleaseNotes();
const { entry } =
[...apiSdkNotes, ...consoleNotes].find((entry) => entry.slug === slug) ?? {};
[...apiSdkNotes, ...consoleNotes, ...platformNotes].find(
(entry) => entry.slug === slug,
) ?? {};
if (!entry) return new Response(null, { status: 404 });
const type = entry.slug.startsWith("api-sdk") ? "apiSdkNotes" : "consoleNotes";
const type = match(entry.slug)
.when(
(v) => v.startsWith("api-sdk"),
() => "apiSdkNotes" as const,
)
.when(
(v) => v.startsWith("console"),
() => "consoleNotes" as const,
)
.when(
(v) => v.startsWith("platform"),
() => "platformNotes" as const,
)
.run();
const { releasedAt, writtenAt } = entry.data;
const { Content } = await entry.render();
const label = {
apiSdkNotes: "API / SDK",
consoleNotes: "관리자콘솔",
platformNotes: "파트너 정산 자동화",
}[type];
const title = `${format(releasedAt, "yyyy-MM-dd")} ${label} 업데이트`;
---
Expand All @@ -44,6 +62,7 @@ const title = `${format(releasedAt, "yyyy-MM-dd")} ${label} 업데이트`;
<Nav
consoleNotes={consoleNotes}
apiSdkNotes={apiSdkNotes}
platformNotes={platformNotes}
activeSlug={slug}
/>
</div>
Expand Down
9 changes: 7 additions & 2 deletions src/pages/release-notes/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import LayoutBase from "~/layouts/LayoutBase.astro";
import Nav from "~/layouts/release-notes/Nav.astro";
import { getReleaseNotes } from "~/misc/releaseNote";
const { consoleNotes, apiSdkNotes } = await getReleaseNotes();
const { consoleNotes, apiSdkNotes, platformNotes } = await getReleaseNotes();
---

<LayoutBase lang="ko" title="포트원 릴리즈노트" slug="release-notes" navAsMenu>
Expand All @@ -19,7 +19,11 @@ const { consoleNotes, apiSdkNotes } = await getReleaseNotes();
<div
class="fixed h-[calc(100%-3.5rem)] w-inherit overflow-y-scroll border-r bg-white"
>
<Nav consoleNotes={consoleNotes} apiSdkNotes={apiSdkNotes} />
<Nav
consoleNotes={consoleNotes}
apiSdkNotes={apiSdkNotes}
platformNotes={platformNotes}
/>
</div>
</aside>
<div class="mx-auto shrink basis-200">
Expand All @@ -36,6 +40,7 @@ const { consoleNotes, apiSdkNotes } = await getReleaseNotes();
[
["관리자콘솔", consoleNotes],
["API / SDK", apiSdkNotes],
["파트너 정산 자동화", platformNotes],
] as const
).map(([title, notes]) => (
<section class="my-4 flex-1 whitespace-nowrap pr-4">
Expand Down

0 comments on commit 76ce98f

Please sign in to comment.