diff --git a/.prettierrc.cjs b/.prettierrc.cjs index 4dc2549..7772ceb 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -1,5 +1,8 @@ module.exports = { - plugins: [require.resolve("prettier-plugin-astro")], + plugins: [ + require.resolve("prettier-plugin-astro"), + require.resolve("prettier-plugin-tailwindcss"), + ], overrides: [ { files: "*.astro", diff --git a/docs/config.ts b/docs/config.ts index 03f62ae..f61dddd 100644 --- a/docs/config.ts +++ b/docs/config.ts @@ -1,8 +1,8 @@ export interface Docs { - sidebar: Sidebar[]; + sidebar: SidebarItem[]; } -export interface Sidebar { +export interface SidebarItem { text: string; header?: boolean; link?: string; @@ -26,6 +26,6 @@ export const docs: Docs = { { text: "Stats", link: "/docs/discord-experiments-api/stats", - } + }, ], }; diff --git a/src/components/widgets/docs/LeftSidebar.astro b/src/components/widgets/docs/LeftSidebar.astro index b8873cb..356d1a7 100644 --- a/src/components/widgets/docs/LeftSidebar.astro +++ b/src/components/widgets/docs/LeftSidebar.astro @@ -1,16 +1,18 @@ --- -import { docs, type Sidebar } from "@docs/config"; +import { docs, type SidebarItem } from "@docs/config"; const { currentPage } = Astro.props; -const currentPageMatch = currentPage.slice(1); +const currentPageMatch = currentPage.slice(1).endsWith("/") + ? currentPage.slice(1).slice(0, -1) + : currentPage.slice(1); -const isCurrentPage = (item: Sidebar) => { +const isCurrentPage = (item: SidebarItem) => { if (item.link) { return item.link.includes(currentPageMatch); } return false; }; -const getLinkClasses = (link: Sidebar) => { +const getLinkClasses = (link: SidebarItem) => { const baseClasses = "py-1 px-6 my-1 transition-colors border-l -ml-px pl-4"; if (isCurrentPage(link)) { diff --git a/src/components/widgets/docs/RightSidebar.astro b/src/components/widgets/docs/RightSidebar.astro index 8598f82..34bb942 100644 --- a/src/components/widgets/docs/RightSidebar.astro +++ b/src/components/widgets/docs/RightSidebar.astro @@ -20,7 +20,7 @@ const headings = item { headings.length > 1 && ( -