Skip to content

Commit

Permalink
feat(docs): add darkmode (#243)
Browse files Browse the repository at this point in the history
Co-authored-by: QuiiBz <tom.lienrd@gmail.com>
  • Loading branch information
Willem-Jaap and QuiiBz authored Oct 14, 2023
1 parent 82c233c commit c3f55b1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
23 changes: 23 additions & 0 deletions docs/components/logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use client';

import Image from 'next/image';
import { useTheme } from 'nextra-theme-docs';
import { useEffect, useState } from 'react';

const Logo = () => {
const { resolvedTheme } = useTheme();
const [src, setSrc] = useState('/logo-black.png');

useEffect(() => {
if (resolvedTheme === 'dark') {
setSrc('/logo-white.png');
return;
}

setSrc('/logo-black.png');
}, [resolvedTheme]);

return <Image src={src} alt="Next International logo" priority width={240} height={200} />;
};

export default Logo;
4 changes: 2 additions & 2 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
const nextConfig = {
reactStrictMode: true,
webpack(config) {
const allowedSvgRegex = /components\/icons\/.+\.svg$/;
const allowedSvgRegex = /\.svg$/;

const fileLoaderRule = config.module.rules.find(rule => rule.test?.test('.svg'));
const fileLoaderRule = config.module.rules.find(rule => rule.test?.test?.('.svg'));
fileLoaderRule.exclude = allowedSvgRegex;

config.module.rules.push({
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tabs, Tab, Cards, Card } from 'nextra/components'
import { AppIcon, PagesIcon } from '../../components/icons'
import { AppIcon, PagesIcon } from '@components/icons'

# Get Started

Expand Down
5 changes: 3 additions & 2 deletions docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ title: Home
---

import { Cards, Card } from 'nextra/components'
import { AppIcon, PagesIcon } from '../components/icons'
import Logo from '@components/logo'
import { AppIcon, PagesIcon } from '@components/icons'

<p align="center">
<img alt="" height="100px" src="/logo-black.png" />
<Logo />
<br />
<span>Type-safe internationalization (i18n) for Next.js</span>
</p>
Expand Down
9 changes: 5 additions & 4 deletions docs/theme.config.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useConfig } from 'nextra-theme-docs'
import { useConfig } from 'nextra-theme-docs';
import Image from 'next/image';

export default {
Expand All @@ -10,7 +10,10 @@ export default {
),
head: () => {
const { title } = useConfig();
const socialCard = process.env.NODE_ENV === 'development' ? 'http://localhost:3000/og.jpg' : 'https://next-international.vercel.app/og.jpg';
const socialCard =
process.env.NODE_ENV === 'development'
? 'http://localhost:3000/og.jpg'
: 'https://next-international.vercel.app/og.jpg';

return (
<>
Expand Down Expand Up @@ -39,9 +42,7 @@ export default {
footer: {
text: <span>MIT {new Date().getFullYear()} © next-international contributors.</span>,
},
darkMode: false,
nextThemes: {
defaultTheme: 'light',
forcedTheme: 'light',
},
};
3 changes: 2 additions & 1 deletion docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"jsx": "preserve",
"incremental": true,
"paths": {
"@/*": ["./*"]
"@/*": ["./*"],
"@components/*": ["./components/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
Expand Down

0 comments on commit c3f55b1

Please sign in to comment.