Skip to content

Commit

Permalink
fix: hotfix show toc by default
Browse files Browse the repository at this point in the history
  • Loading branch information
jer3m01 committed Nov 15, 2024
1 parent bca6a78 commit e0650d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions src/client/page-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,25 @@ function createPageData() {
const pd = (mod?.$$SolidBase_page_data ??
defaultPageData) as CurrentPageData;

// @ts-ignore
pd.layout ??= {};
pd.layout = defaultPageData.layout;

pd.layout!.prev = pd.frontmatter.prev;
pd.layout!.next = pd.frontmatter.next;

switch (pd.frontmatter.layout) {
case "home":
pd.layout!.editLink ??= false;
pd.layout!.lastUpdated ??= false;
pd.layout!.next ??= false;
pd.layout!.prev ??= false;
pd.layout!.sidebar ??= false;
pd.layout!.toc ??= false;
pd.layout!.footer ??= true;
pd.layout!.editLink = false;
pd.layout!.lastUpdated = false;
pd.layout!.next = false;
pd.layout!.prev = false;
pd.layout!.sidebar = false;
pd.layout!.toc = false;
pd.layout!.footer = true;
}

for (const k in Object.keys(pd.layout ?? {})) {
// @ts-ignore
if (pd.frontmatter[k]) pd.layout[k] = pd.frontmatter[k];
}

return pd;
Expand Down
2 changes: 1 addition & 1 deletion src/default-theme/components/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function Article(props: ParentProps) {
</Show>
</div>

<Show when={!mobileLayout() && pageData().layout?.toc}>
<Show when={!mobileLayout() && (pageData().layout?.toc ?? true)}>
<aside class={styles.aside}>
<TableOfContents />
</aside>
Expand Down

0 comments on commit e0650d5

Please sign in to comment.