Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboyd committed Jul 27, 2023
1 parent da4d1a5 commit db58f5d
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions www/html/document.html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ export default function* (doc: Doc): Operation<JSX.Element> {
behavior: "append",
properties: {
className:
"opacity-0 group-hover:opacity-100 after:content-['#']",
"opacity-0 group-hover:opacity-100 after:content-['#']",
},
}],
[rehypeAddClasses, {
"h1[id],h2[id],h3[id],h4[id],h5[id],h6[id]": "group",
}],
[rehypeToc, {
cssClasses: {
toc: "hidden text-sm tracking-wide leading-loose lg:block relative whitespace-nowrap",
toc:
"hidden text-sm tracking-wide leading-loose lg:block relative whitespace-nowrap",
list: "fixed",
},
}],
Expand All @@ -102,23 +103,23 @@ function NextPrevLinks({ doc }: { doc: Doc }): JSX.Element {
return (
<menu class="grid grid-cols-2">
{doc.previous
? (
<li class="col-start-1 text-left">
Previous
<a class="block" href={`/docs/${doc.previous.id}`}>
‹‹{doc.previous.title}
</a>
</li>
)
: ""}
? (
<li class="col-start-1 text-left">
Previous
<a class="block" href={`/docs/${doc.previous.id}`}>
‹‹{doc.previous.title}
</a>
</li>
)
: ""}
{doc.next
? (
<li class="col-start-2 text-right">
Next
<a class="block" href={`/docs/${doc.next.id}`}>{doc.next.title}</a>
</li>
)
: ""}
? (
<li class="col-start-2 text-right">
Next
<a class="block" href={`/docs/${doc.next.id}`}>{doc.next.title}</a>
</li>
)
: ""}
</menu>
);
}
Expand All @@ -130,10 +131,12 @@ import { Transform } from "./components/transform.tsx";
* of the article, not contained within it.
*/
function liftTOC(element: JSX.Element): JSX.Element {
if (element.type !== 'element') {
if (element.type !== "element") {
return element;
}
let nav = element.children.find(child => child.type === 'element' && child.tagName === "nav");
let nav = element.children.find((child) =>
child.type === "element" && child.tagName === "nav"
);
if (!nav) {
return element;
}
Expand All @@ -142,9 +145,9 @@ function liftTOC(element: JSX.Element): JSX.Element {
children: [
{
...element,
children: element.children.filter(child => child !== nav)
children: element.children.filter((child) => child !== nav),
},
nav,
]
}
],
};
}

0 comments on commit db58f5d

Please sign in to comment.