Skip to content

Commit

Permalink
Merge pull request #871 from push-protocol/864-the-footer-bottom
Browse files Browse the repository at this point in the history
Fix Footer Position in 404-page
  • Loading branch information
rohitmalhotra1420 authored Sep 18, 2024
2 parents 3d47648 + 21069c1 commit 4f45da5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
17 changes: 13 additions & 4 deletions src/theme/NotFound/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ import type { Props } from '@theme/NotFound/Content';
import Heading from '@theme/Heading';
import { Content, Section } from '@site/src/css/SharedStyling';
import { useLocation } from '@docusaurus/router';
import styled from 'styled-components';

// Internal Components
import Footer from '@site/src/segments/Footer';

export default function NotFoundContent({ className }: Props): JSX.Element {
const location = useLocation();
const pathname = location.pathname;

// Determine if the pathname starts with '/docs'
const isDocsPage = location.pathname.startsWith('/docs');

return (
<>
<PageContainer isDocsPage={isDocsPage!}>
<Section>
<Content>
<main className={clsx('container margin-vert--xl', className)}>
Expand Down Expand Up @@ -58,7 +61,13 @@ export default function NotFoundContent({ className }: Props): JSX.Element {
</Content>
</Section>

{location.pathname.startsWith('/docs') && <Footer />}
</>
{isDocsPage && <Footer />}
</PageContainer>
);
}

const PageContainer = styled.div<{ isDocsPage?: boolean }>`
display: flex;
flex-direction: column;
${({ isDocsPage }) => isDocsPage && 'min-height: 100vh;'};
`;
7 changes: 3 additions & 4 deletions src/theme/NotFound/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
* LICENSE file in the root directory of this source tree.
*/

// External Components
import React from 'react';

// Internal Components
import { translate } from '@docusaurus/Translate';
import { PageMetadata } from '@docusaurus/theme-common';
import Layout from '@theme/Layout';
import NotFoundContent from '@theme/NotFound/Content';
import { useLocation } from '@docusaurus/router';

// Internal Components
import Footer from '@site/src/segments/Footer';

export default function Index(): JSX.Element {
const location = useLocation();
const pathname = location.pathname;

const title = translate({
id: 'theme.NotFound.title',
Expand Down
20 changes: 16 additions & 4 deletions src/theme/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';

// External Components
import i18nInitialize from '@site/src/utils/i18n';
import styled from 'styled-components';

// Internal Components
import Footer from '@site/src/segments/Footer';
Expand Down Expand Up @@ -60,7 +61,7 @@ export default function Root({ children }) {
}

// check if location path exists
function locationPathExists(pathname, condition, comingfrom = null) {
function locationPathExists(pathname, condition) {
let result = false;
pathname = pathname.toUpperCase();

Expand Down Expand Up @@ -98,11 +99,11 @@ export default function Root({ children }) {
}

return (
<div className={returnAdditionalClasses(superimposedConditions)}>
<PageContainer className={returnAdditionalClasses(superimposedConditions)}>
<ServerStyle from={children} />

{/* Main react children */}
{children}
<Content>{children}</Content>

{excludeDefaultConfigAt('/BRB') &&
excludeDefaultConfigAt('/DOCS') &&
Expand All @@ -112,6 +113,17 @@ export default function Root({ children }) {
<CookieComponent />
</>
)}
</div>
</PageContainer>
);
}

const PageContainer = styled.div`
display: flex;
flex-direction: column;
min-height: 100vh;
`;

// The main content should take up all remaining space
const Content = styled.div`
flex: 1;
`;

0 comments on commit 4f45da5

Please sign in to comment.