Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lino-levan committed Aug 2, 2023
1 parent 7177363 commit ae63a5a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
8 changes: 4 additions & 4 deletions page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JSX } from "./src/lib/types.ts"
import { JSX } from "./src/lib/types.ts";

export type PageProps = {
header: JSX.Element,
footer?: JSX.Element
}
header: JSX.Element;
footer?: JSX.Element;
};
20 changes: 16 additions & 4 deletions src/lib/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,22 @@ export async function render(
config,
dev,
magic,
body: renderToString(await userPage({
header: Header({title: config.title, header: getHeaderElements(config, plugins), github: config.github}),
footer: config.footer ? Footer({copyright: config.copyright, github: config.github, footer: config.footer}) : undefined
})),
body: renderToString(
await userPage({
header: Header({
title: config.title,
header: getHeaderElements(config, plugins),
github: config.github,
}),
footer: config.footer
? Footer({
copyright: config.copyright,
github: config.github,
footer: config.footer,
})
: undefined,
}),
),
},
}),
),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface Config {
title: string;
github?: string;
copyright?: string;
header?: { left?: string[], right?: string[] }
header?: { left?: string[]; right?: string[] };
footer?: Record<string, string[]>;
plugins?: string[];
}
Expand Down
30 changes: 23 additions & 7 deletions src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import remarkGfm from "remark-gfm";
import rehypeHighlight from "rehype-prism";
import { compile } from "mdx";
import { render } from "gfm";
import type { Config, FileTypes, JSX, Plugin, PluginResult } from "./lib/types.ts";
import type {
Config,
FileTypes,
JSX,
Plugin,
PluginResult,
} from "./lib/types.ts";

import "prism/components/prism-markdown?no-check";
import "prism/components/prism-jsx?no-check";
Expand Down Expand Up @@ -63,14 +69,24 @@ export function loadPlugins(plugins: string[]) {

export function getHeaderElements(config: Config, plugins: PluginResult[]) {
const header: {
left: JSX.Element[],
right: JSX.Element[]
left: JSX.Element[];
right: JSX.Element[];
} = {
left: config.header?.left?.map((value)=>(
<a class="hover:text-gray-500 dark:hover:text-gray-400" href={value.split(" ").pop()}>{value.split(" ").slice(0, -1).join(" ")}</a>
left: config.header?.left?.map((value) => (
<a
class="hover:text-gray-500 dark:hover:text-gray-400"
href={value.split(" ").pop()}
>
{value.split(" ").slice(0, -1).join(" ")}
</a>
)) ?? [],
right: config.header?.right?.map((value)=>(
<a class="hover:text-gray-500 dark:hover:text-gray-400" href={value.split(" ").pop()}>{value.split(" ").slice(0, -1).join(" ")}</a>
right: config.header?.right?.map((value) => (
<a
class="hover:text-gray-500 dark:hover:text-gray-400"
href={value.split(" ").pop()}
>
{value.split(" ").slice(0, -1).join(" ")}
</a>
)) ?? [],
};

Expand Down

0 comments on commit ae63a5a

Please sign in to comment.