chore: consistent formatting (#47)

This commit is contained in:
Christian Pillsbury
2025-10-09 12:18:31 -07:00
committed by GitHub
parent 9c6eaef2aa
commit 9c5b29a15b
35 changed files with 193 additions and 180 deletions
+3 -7
View File
@@ -1,4 +1,5 @@
import type { SupportedFramework, SupportedStyle } from '@/types/docs';
import { findFirstGuide } from '@/utils/docs/sidebar';
/**
@@ -11,16 +12,11 @@ import { findFirstGuide } from '@/utils/docs/sidebar';
* @returns The full docs URL to redirect to
* @throws Error if no guide is available for the given framework/style
*/
export function getDocsRedirectUrl<F extends SupportedFramework>(
framework: F,
style: SupportedStyle<F>,
): string {
export function getDocsRedirectUrl<F extends SupportedFramework>(framework: F, style: SupportedStyle<F>): string {
const firstGuide = findFirstGuide(framework, style);
if (!firstGuide) {
throw new Error(
`No guide available for framework "${framework}" and style "${style}"`,
);
throw new Error(`No guide available for framework "${framework}" and style "${style}"`);
}
return `/docs/framework/${framework}/style/${style}/${firstGuide}/`;
+5 -18
View File
@@ -1,12 +1,7 @@
import type { AnySupportedStyle, Guide, Section, Sidebar, SupportedFramework, SupportedStyle } from '@/types/docs';
import { sidebar } from '@/config/docs/sidebar';
import {
getAvailableStyles,
isSection,
} from '@/types/docs';
import { getAvailableStyles, isSection } from '@/types/docs';
/**
* Check if an item (Guide or Section) should be shown based on framework and style.
@@ -18,13 +13,8 @@ import {
* @param style - The currently selected style
* @returns true if the item should be visible
*/
function isItemVisible(
item: Guide | Section,
framework: SupportedFramework,
style: AnySupportedStyle,
): boolean {
const frameworkMatch
= !item.frameworks || item.frameworks.includes(framework);
function isItemVisible(item: Guide | Section, framework: SupportedFramework, style: AnySupportedStyle): boolean {
const frameworkMatch = !item.frameworks || item.frameworks.includes(framework);
const styleMatch = !item.styles || item.styles.includes(style);
return frameworkMatch && styleMatch;
}
@@ -133,10 +123,7 @@ export function getAllGuideSlugs(sidebarToExtract: Sidebar = sidebar): string[]
* @param sidebarToSearch - Optional sidebar to search (defaults to main sidebar config)
* @returns The guide object if found, null otherwise
*/
export function findGuideBySlug(
slug: string,
sidebarToSearch: Sidebar = sidebar,
): Guide | null {
export function findGuideBySlug(slug: string, sidebarToSearch: Sidebar = sidebar): Guide | null {
for (const item of sidebarToSearch) {
if (isSection(item)) {
// Recursively search section contents
+3 -6
View File
@@ -1,4 +1,5 @@
import type { ParseDataOptions } from 'astro/loaders';
import { glob } from 'astro/loaders';
/**
@@ -7,7 +8,7 @@ import { glob } from 'astro/loaders';
*/
type Parser = <TData extends Record<string, unknown>>(
options: ParseDataOptions<TData>,
originalEntry: string,
originalEntry: string
) => Promise<ParseDataOptions<TData>>;
type GlobWithParserOptions = Parameters<typeof glob>[0] & {
@@ -36,11 +37,7 @@ type GlobWithParserOptions = Parameters<typeof glob>[0] & {
* })
* ```
*/
export function globWithParser({
parser,
generateId,
...globOptions
}: GlobWithParserOptions) {
export function globWithParser({ parser, generateId, ...globOptions }: GlobWithParserOptions) {
/**
* Store mapping of transformed IDs to original entry filenames.
* Created per-invocation to avoid memory leaks across builds.