Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add additional layout options to modern template #9737

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/docs/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Name | Type | Description
`_gitContribute` | object | Defines the `repo` and `branch` property of git links.
`_gitUrlPattern` | string | URL pattern of git links.
`_disableNewTab` | bool | Whether to render external link indicator icons and open external links in a new tab.
`_disableNavbar` | bool | Whether to show the navigation bar.
`_disableBreadcrumb` | bool | Whether to show the breadcrumb.
`_disableToc` | bool | Whether to show the TOC.
`_disableAffix` | bool | Whether to show the right rail.
`_disableNextArticle` | bool | Whether to show the previous and next article link.
`_disableTocFilter` | bool | Whether to show the table of content filter box.
`_googleAnalyticsTagId` | string | Enables Google Analytics web traffic analysis.
Expand Down
10 changes: 10 additions & 0 deletions templates/modern/layout/_master.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

<body class="tex2jax_ignore" data-layout="{{_layout}}{{layout}}" data-yaml-mime="{{yamlmime}}">
<header class="bg-body border-bottom">
{{^_disableNavbar}}
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
<div class="container-xxl flex-nowrap">
<a class="navbar-brand" href="{{_appLogoUrl}}{{^_appLogoUrl}}{{_rel}}index.html{{/_appLogoUrl}}">
Expand All @@ -81,9 +82,11 @@
</div>
</div>
</nav>
{{/_disableNavbar}}
</header>

<main class="container-xxl">
{{^_disableToc}}
<div class="toc-offcanvas">
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
<div class="offcanvas-header">
Expand All @@ -95,16 +98,21 @@
</div>
</div>
</div>
{{/_disableToc}}

<div class="content">
<div class="actionbar">
{{^_disableToc}}
<button class="btn btn-lg border-0 d-md-none" style="margin-top: -.65em; margin-left: -.8em"
type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas"
aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
<i class="bi bi-list"></i>
</button>
{{/_disableToc}}

{{^_disableBreadcrumb}}
<nav id="breadcrumb"></nav>
{{/_disableBreadcrumb}}
</div>

<article data-uid="{{uid}}">
Expand All @@ -128,9 +136,11 @@

</div>

{{^_disableAffix}}
<div class="affix">
<nav id="affix"></nav>
</div>
{{/_disableAffix}}
</main>

{{#_enableSearch}}
Expand Down
1 change: 0 additions & 1 deletion templates/modern/src/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ body[data-layout="landing"] {
display: flex;
align-items: flex-start;
margin-top: .5rem;
min-height: 40px;
}

article {
Expand Down
2 changes: 1 addition & 1 deletion templates/modern/src/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type NavItemContainer = {
export async function renderNavbar(): Promise<NavItem[]> {
const navbar = document.getElementById('navbar')
if (!navbar) {
return
return []
}

const { iconLinks } = await options()
Expand Down