Fix website export & enhance docs page linking

This commit is contained in:
Pascal Jufer 2023-10-29 04:09:56 +01:00
parent 9789d64baf
commit 90fdaa6303
No known key found for this signature in database
4 changed files with 14 additions and 9 deletions

View file

@ -32,7 +32,9 @@ export function Header({ currentVersion }: HeaderProps) {
<HeaderCenter> <HeaderCenter>
<MobileMenuContainer $visible={menuVisible}> <MobileMenuContainer $visible={menuVisible}>
<NavigationItem href={'/'}>Icons</NavigationItem> <NavigationItem href={'/'}>Icons</NavigationItem>
<NavigationItem href={'/docs'}>Documentation</NavigationItem> <NavigationItem href={'/docs/introduction'} activeMatch={'/docs'}>
Documentation
</NavigationItem>
<NavigationItem href={'/support'} style={{ marginRight: 0 }}> <NavigationItem href={'/support'} style={{ marginRight: 0 }}>
Donate &mdash; Our Mission Donate &mdash; Our Mission
</NavigationItem> </NavigationItem>

View file

@ -7,10 +7,16 @@ import { Text15 } from './Typography';
export interface NavigationItemProps { export interface NavigationItemProps {
href: string; href: string;
activeMatch?: string;
children: React.ReactElement | string; children: React.ReactElement | string;
style?: any; style?: any;
} }
export function NavigationItem({ href, children, style }: NavigationItemProps) { export function NavigationItem({
href,
activeMatch,
children,
style,
}: NavigationItemProps) {
const router = useRouter(); const router = useRouter();
return ( return (
@ -20,7 +26,9 @@ export function NavigationItem({ href, children, style }: NavigationItemProps) {
style={style} style={style}
$text={children.toString()} $text={children.toString()}
$isActive={ $isActive={
href.slice(1) activeMatch
? router.asPath.startsWith(activeMatch)
: href.slice(1)
? router.asPath.slice(1).startsWith(href.slice(1)) ? router.asPath.slice(1).startsWith(href.slice(1))
: router.asPath === href : router.asPath === href
} }

View file

@ -1,5 +1,6 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
output: 'export',
reactStrictMode: true, reactStrictMode: true,
compiler: { compiler: {
styledComponents: true, styledComponents: true,
@ -7,11 +8,6 @@ const nextConfig = {
images: { images: {
unoptimized: true, unoptimized: true,
}, },
async redirects() {
return [
{ source: '/docs', destination: '/docs/introduction', permanent: true },
];
},
}; };
module.exports = nextConfig; module.exports = nextConfig;

View file

@ -4,7 +4,6 @@
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",
"export": "next export",
"start": "next start", "start": "next start",
"lint": "next lint" "lint": "next lint"
}, },