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

fix: page layout when code editor is presented #929

Merged
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
10 changes: 8 additions & 2 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));

const cfPagesBranch = process.env.CF_PAGES_BRANCH;

// https://community.cloudflare.com/t/algorithm-to-generate-a-preview-dns-subdomain-from-a-branch-name/477633/2
const getCloudflareSubdomain = (branchName: string) =>
branchName
.replace(/[^a-z0-9-]/g, '-')
.substring(0, 28)
.replace(/^-|-$/, '');

const getLogtoDocsUrl = () =>
cfPagesBranch && cfPagesBranch !== 'master'
// https://community.cloudflare.com/t/algorithm-to-generate-a-preview-dns-subdomain-from-a-branch-name/477633/2
? `https://${cfPagesBranch.substring(0, 28).replace(/[^a-z0-9-]/g, '-')}.logto-docs.pages.dev/`
? `https://${getCloudflareSubdomain(cfPagesBranch)}.logto-docs.pages.dev/`
: 'https://docs.logto.io/';

const { dracula } = themes;
Expand Down
2 changes: 1 addition & 1 deletion src/theme/CodeBlock/Content/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
font: inherit;
/* rtl:ignore */
float: left;
min-width: 100%;
width: 100%;
padding: var(--ifm-pre-padding);
}

Expand Down
11 changes: 8 additions & 3 deletions src/theme/DocItem/Layout/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
}

.desktopToc {
flex: 0 0 276px;
display: none;
}

@media (max-width: 996px) {
@media (min-width: 997px) {
.desktopToc {
display: none;
display: block;
flex: 0 0 276px;
}

.main.hasDesktopToc {
max-width: min(1000px, calc(100vw - 680px));
}
}
10 changes: 6 additions & 4 deletions src/theme/DocItem/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
import DocVersionBadge from '@theme/DocVersionBadge';
import DocVersionBanner from '@theme/DocVersionBanner';
import clsx from 'clsx';

import styles from './index.module.scss';

Expand Down Expand Up @@ -38,25 +39,26 @@ function useDocTOC() {
}

export default function DocItemLayout({ children }: Props): JSX.Element {
const docTOC = useDocTOC();
const { hidden, mobile: mobileToc, desktop: desktopToc } = useDocTOC();
const { metadata } = useDoc();
const hasDesktopToc = !hidden && !!desktopToc;
return (
<div className={styles.layout}>
<div className={styles.main}>
<div className={clsx(styles.main, hasDesktopToc && styles.hasDesktopToc)}>
<ContentVisibility metadata={metadata} />
<DocVersionBanner />
<div className={styles.docItemContainer}>
<article>
<DocBreadcrumbs />
<DocVersionBadge />
{docTOC.mobile}
{mobileToc}
<DocItemContent>{children}</DocItemContent>
<DocItemFooter />
</article>
<DocItemPaginator />
</div>
</div>
{docTOC.desktop && <div className={styles.desktopToc}>{docTOC.desktop}</div>}
{hasDesktopToc && <div className={styles.desktopToc}>{desktopToc}</div>}
</div>
);
}
Loading