chore(cleanup): add docs + cleanup
+ 51
- 13
@@ -2,9 +2,6 @@ import React, { PropsWithChildren } from "react";
 
 import AppRouter from "./islands/AppRouter";
 
-// import { AppRoute } from "./routes.defs";
-// import HomeView from "./views/HomeView";
-
 export function App({ children }: PropsWithChildren<{}>) {
   return (
     <>

app/components/Layout.tsx
@@ -131,10 +131,11 @@ const LayoutComponent: FC<LayoutProps & WithThemeSchemeProp> = (props) => {
 };
 
 // wrap and export the Layout as named export
-const _LayoutWithCounters = withLayoutCounters(
-  LayoutComponent as NonNullable<() => JSX.Element>,
-);
-export const Layout = _LayoutWithCounters;
+// const _LayoutWithCounters = withLayoutCounters(
+//   LayoutComponent as NonNullable<() => JSX.Element>,
+// );
+withLayoutCounters;
+export const Layout = LayoutComponent as NonNullable<() => JSX.Element>;
 
 /* Styled components (unchanged from previous layout structure) */
 const StyledLayoutWrapper = styled.div<WithThemeSchemeProp>`

app/utils/shared/buildRouteLink.ts
@@ -5,23 +5,39 @@ interface BuildLinkOptions {
   encodeURIComponent?: boolean | number;
 }
 
+/**
+ * Builds a route link for the given route and route parameters.
+ *
+ * @param route - The route to build a link for.
+ * @param routeParams - The route parameters to use in the link.
+ * @param options - Optional build link options.
+ * @returns The built route link.
+ */
 export default function buildRouteLink<P extends AppRoute>(
   route: P,
   routeParams: "params" extends keyof AppRouteParams[P]
     ? AppRouteParams[P]["params"]
     : {} | null,
-  options?: BuildLinkOptions
+  options?: BuildLinkOptions,
 ): (typeof AppRoutePaths)[P] {
   const path = AppRoutePaths[route];
   return buildPathLink(path, routeParams, options);
 }
 
+/**
+ * Builds a path link for the given path and route parameters.
+ *
+ * @param path - The path to build a link for.
+ * @param routeParams - The route parameters to use in the link.
+ * @param options - Optional build link options.
+ * @returns The built path link.
+ */
 export function buildPathLink<P extends AppRoute>(
   path: string,
   routeParams: "params" extends keyof AppRouteParams[P]
     ? AppRouteParams[P]["params"]
     : {} | null,
-  options?: BuildLinkOptions
+  options?: BuildLinkOptions,
 ): string {
   if (
     routeParams == null ||

...
@@ -67,7 +83,7 @@ export function buildPathLink<P extends AppRoute>(
 
   return linkBuilder
     .map((param) =>
-      shouldEncodeURIComponents ? encodeURIComponent(param) : param
+      shouldEncodeURIComponents ? encodeURIComponent(param) : param,
     )
     .join("/");
 }

app/utils/shared/escapeHtmlCode.ts
@@ -1,4 +1,10 @@
-export function escapeHtmlCode(text: string): string {
+/**
+ * Escapes HTML code in the given text.
+ *
+ * @param text - The text to escape.
+ * @returns The escaped text.
+ */
+export default function escapeHtmlCode(text: string): string {
   return (text || "")
     .split(/&/gm)
     .join("&amp;")

app/utils/shared/getFormEntries.ts
@@ -1,5 +1,11 @@
+/**
+ * Gets the entries from a form element as a record.
+ *
+ * @param form - The form element to get entries from.
+ * @returns The form entries as a record.
+ */
 export default function getFormEntries<
-  R extends Record<string, unknown> = Record<string, unknown>
+  R extends Record<string, unknown> = Record<string, unknown>,
 >(form: HTMLFormElement): R {
   return Object.values(form).reduce((obj, field) => {
     obj[field.name] = field.value;

app/utils/shared/getGitdiffLineStart.ts
@@ -1,3 +1,9 @@
+/**
+ * Gets the line start positions from a git diff string.
+ *
+ * @param maybeGitdiff - The git diff string to parse.
+ * @returns The line start positions as an object.
+ */
 export default function getGitdiffLineStart(maybeGitdiff: string): {
   before: number;
   after: number;

app/utils/shared/index.ts
@@ -1,4 +1,4 @@
-export { escapeHtmlCode } from "./escapeHtmlCode";
+export { default as escapeHtmlCode } from "./escapeHtmlCode";
 export { default as buildRouteLink } from "./buildRouteLink";
 export { default as getFormEntries } from "./getFormEntries";
 export { default as getGitdiffLineStart } from "./getGitdiffLineStart";

app/utils/shared/slugify.ts
@@ -1,3 +1,9 @@
+/**
+ * Slugifies a string by replacing spaces with hyphens and removing non-word characters.
+ *
+ * @param str - The string to slugify.
+ * @returns The slugified string.
+ */
 export default function slugify(str: string): string {
   return str
     .toString()