chore: Fix icon view for nav
This commit is contained in:
parent
4697fbd999
commit
1745469bb0
5 changed files with 20 additions and 14 deletions
|
@ -81,9 +81,9 @@ export const Header = ({ app, setSearch }) => {
|
|||
onClick={() => setSearch(true)}
|
||||
>
|
||||
<SearchIcon />
|
||||
<keyb className="px-3 rounded text-base font-medium border border-solid border-base-300">
|
||||
<span className="px-3 rounded text-base font-medium border border-solid border-base-300">
|
||||
/
|
||||
</keyb>
|
||||
</span>
|
||||
</button>
|
||||
<ThemePicker app={app} />
|
||||
</div>
|
||||
|
|
|
@ -157,9 +157,11 @@ export const Icons = ({
|
|||
flex flex-col items-center`,
|
||||
linkStyle = {},
|
||||
}) => {
|
||||
if (!app.navigation) return null
|
||||
console.log(app.state)
|
||||
if (!app.state?.nav) return null
|
||||
|
||||
const output = []
|
||||
for (const page of order(app.navigation)) {
|
||||
for (const page of order(app.state.nav)) {
|
||||
output.push(
|
||||
<li key={page.s}>
|
||||
<Link href={`${page.s}`} className={linkClasses} title={page.t} style={linkStyle}>
|
||||
|
|
|
@ -37,13 +37,14 @@ const createSections = () => {
|
|||
export const loadNavigation = (path = []) => {
|
||||
// Creat crumbs array
|
||||
const crumbs = createCrumbs(path)
|
||||
const sections = createSections()
|
||||
|
||||
return {
|
||||
path,
|
||||
slug: path.join('/'),
|
||||
crumbs,
|
||||
sections: createSections(),
|
||||
nav: path.length > 1 ? get(pbn.en, path[0]) : pbn.en[path[0]],
|
||||
title: crumbs.slice(-1)[0].t,
|
||||
sections,
|
||||
nav: path.length > 1 ? get(pbn.en, path[0]) : path.length === 0 ? sections : pbn.en[path[0]],
|
||||
title: crumbs.length > 0 ? crumbs.slice(-1)[0].t : '',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
|||
import Head from 'next/head'
|
||||
import { PageWrapper } from 'shared/components/wrappers/page.mjs'
|
||||
import { BareLayout } from 'site/components/layouts/bare.mjs'
|
||||
import { Icons } from 'shared/components/navigation/primary.mjs'
|
||||
import { Icons } from 'site/components/navigation/primary.mjs'
|
||||
import { Highlight } from 'shared/components/mdx/highlight.mjs'
|
||||
import { Popout } from 'shared/components/popout.mjs'
|
||||
import { WebLink } from 'shared/components/web-link.mjs'
|
||||
|
@ -14,8 +14,8 @@ import { PageLink } from 'shared/components/page-link.mjs'
|
|||
|
||||
const title = 'Welcome to FreeSewing.dev'
|
||||
|
||||
const HomePage = () => {
|
||||
const app = useApp()
|
||||
const HomePage = (props) => {
|
||||
const app = useApp(props)
|
||||
return (
|
||||
<PageWrapper app={app} title={title} layout={BareLayout}>
|
||||
<Head>
|
||||
|
@ -71,7 +71,6 @@ const HomePage = () => {
|
|||
</div>
|
||||
<Icons
|
||||
app={app}
|
||||
active="/"
|
||||
ulClasses="grid grid-cols-2 gap-4 lg:grid-cols-4 lg:gap-8 mt-8 max-w-6xl"
|
||||
liClasses=""
|
||||
linkClasses={`
|
||||
|
@ -206,7 +205,6 @@ const HomePage = () => {
|
|||
<div className="px-8 text-base-content">
|
||||
<Icons
|
||||
app={app}
|
||||
active="/"
|
||||
ulClasses="grid grid-cols-2 gap-4 w-full lg:grid-cols-4 lg:gap-8 mt-8 max-w-6xl"
|
||||
liClasses=""
|
||||
linkClasses={`
|
||||
|
@ -227,6 +225,9 @@ export async function getStaticProps() {
|
|||
return {
|
||||
props: {
|
||||
...(await serverSideTranslations('en')),
|
||||
page: {
|
||||
path: [],
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,9 @@ const defaultState = {
|
|||
*/
|
||||
export function useApp(props = {}) {
|
||||
const { bugsnag = false, page = {}, loadState = {} } = props
|
||||
const { path = [] } = page
|
||||
const { path = false } = page
|
||||
|
||||
if (!path) throw 'You MUST pass a page.path prop to the useApp hook'
|
||||
|
||||
const reportError = useBugsnag(props?.bugsnag)
|
||||
|
||||
|
@ -29,7 +31,7 @@ export function useApp(props = {}) {
|
|||
|
||||
useEffect(() => {
|
||||
// Force update of navigation info (nav, title, crumbs) on each page change
|
||||
if (path.length > 0) setState({ ...state, ...loadNavigation(path) })
|
||||
if (path) setState({ ...state, ...loadNavigation(path) })
|
||||
}, [path, state.slug, state.title])
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue