This commit is contained in:
Trance-0
2025-10-27 15:12:02 -05:00
parent f634254bca
commit 1476e7f1c2
4 changed files with 16 additions and 17 deletions

View File

@@ -1,12 +1,13 @@
/* eslint-env node */
import { Footer, Layout, Navbar, useThemeConfig } from 'nextra-theme-docs'
import { Banner, Head } from 'nextra/components'
import { Footer, Layout} from 'nextra-theme-docs'
import { Head } from 'nextra/components'
import { getPageMap } from 'nextra/page-map'
import 'nextra-theme-docs/style.css'
import { SpeedInsights } from "@vercel/speed-insights/next"
import { Analytics } from "@vercel/analytics/react"
import 'katex/dist/katex.min.css'
import AlgoliaSearch from '../components/docsearch'
import { Navbar } from '../components/navbar'
export const metadata = {
metadataBase: new URL('https://notenextra.trance-0.com'),
@@ -31,12 +32,13 @@ export const metadata = {
}
export default async function RootLayout({ children }) {
const { darkMode } = useThemeConfig()
const pageMap = await getPageMap();
const navbar = (
<Navbar
pageMap={pageMap}
logo={
<>
<svg width="32" height="32" viewBox="0 0 16 16">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" className="bi bi-braces-asterisk" viewBox="0 0 16 16">
<path fillRule="evenodd" d="M1.114 8.063V7.9c1.005-.102 1.497-.615 1.497-1.6V4.503c0-1.094.39-1.538 1.354-1.538h.273V2h-.376C2.25 2 1.49 2.759 1.49 4.352v1.524c0 1.094-.376 1.456-1.49 1.456v1.299c1.114 0 1.49.362 1.49 1.456v1.524c0 1.593.759 2.352 2.372 2.352h.376v-.964h-.273c-.964 0-1.354-.444-1.354-1.538V9.663c0-.984-.492-1.497-1.497-1.6M14.886 7.9v.164c-1.005.103-1.497.616-1.497 1.6v1.798c0 1.094-.39 1.538-1.354 1.538h-.273v.964h.376c1.613 0 2.372-.759 2.372-2.352v-1.524c0-1.094.376-1.456 1.49-1.456v-1.3c-1.114 0-1.49-.362-1.49-1.456V4.352C14.51 2.759 13.75 2 12.138 2h-.376v.964h.273c.964 0 1.354.444 1.354 1.538V6.3c0 .984.492 1.497 1.497 1.6M7.5 11.5V9.207l-1.621 1.621-.707-.707L6.792 8.5H4.5v-1h2.293L5.172 5.879l.707-.707L7.5 6.792V4.5h1v2.293l1.621-1.621.707.707L9.208 7.5H11.5v1H9.207l1.621 1.621-.707.707L8.5 9.208V11.5z"/>
</svg>
<span style={{ marginLeft: '.4em', fontWeight: 800 }}>
@@ -47,7 +49,6 @@ export default async function RootLayout({ children }) {
projectLink="https://github.com/Trance-0/NoteNextra"
/>
)
const pageMap = await getPageMap()
return (
<html lang="en" dir="ltr" suppressHydrationWarning>
<Head color={{
@@ -83,7 +84,7 @@ export default async function RootLayout({ children }) {
sidebar={{ defaultMenuCollapseLevel: 1 }}
pageMap={pageMap}
// TODO: fix algolia search
search={<AlgoliaSearch darkMode={darkMode} />}
search={<AlgoliaSearch/>}
>
{children}
{/* SpeedInsights in vercel */}

View File

@@ -2,16 +2,20 @@
// sample code from https://docsearch.algolia.com/docs/docsearch
import { DocSearch } from '@docsearch/react';
import {useTheme} from 'next-themes';
import '@docsearch/css';
function AlgoliaSearch({ darkMode }: { darkMode: boolean }) {
function AlgoliaSearch () {
const {theme} = useTheme();
const darkMode = theme === 'dark';
console.log("darkMode", darkMode);
return (
<DocSearch
appId={process.env.NEXT_SEARCH_ALGOLIA_APP_ID || 'NKGLZZZUBC'}
indexName={process.env.NEXT_SEARCH_ALGOLIA_INDEX_NAME || 'notenextra_trance_0'}
apiKey={process.env.NEXT_SEARCH_ALGOLIA_API_KEY || '727b389a61e862e590dfab9ce9df31a2'}
theme={darkMode ? 'dark' : 'light'}
theme={darkMode===false ? 'light' : 'dark'}
/>
);
}

View File

@@ -108,20 +108,16 @@ export const ClientNavbar: FC<{
item => !('href' in item)
).map(item => item.title)
)
console.log(existingCourseNames)
console.log('existingCourseNames', existingCourseNames)
// filter out elements in topLevelNavbarItems with url but have title in existingCourseNames
const filteredTopLevelNavbarItems = topLevelNavbarItems.filter(item => !('href' in item && existingCourseNames.has(item.title)))
console.log('filteredTopLevelNavbarItems', filteredTopLevelNavbarItems)
// or even better, remove all old doc page generated links
// this don't make sense because it will destroy the navbar structure highlight for children pages
// const filteredTopLevelNavbarItems = topLevelNavbarItems.filter(item => !('firstChildRoute' in item))
// const items = topLevelNavbarItems
// use filteredTopLevelNavbarItems to generate items
const items = filteredTopLevelNavbarItems
console.log(filteredTopLevelNavbarItems)
const themeConfig = useThemeConfig()
const pathname = useFSRoute()

View File

@@ -4,10 +4,8 @@
'use client'
import { usePathname } from 'next/navigation'
import type { PageMapItem } from 'nextra'
import { Anchor } from 'nextra/components'
import { normalizePages } from 'nextra/normalize-pages'
import type { FC, ReactNode } from 'react'
import cn from 'clsx'