From 01f4aa44cc1d4e7356ae3e4565b6d978fad43054 Mon Sep 17 00:00:00 2001 From: Saurav Panda Date: Mon, 23 Dec 2024 00:34:36 -0800 Subject: [PATCH] feat: highlight the header based on the page you are at --- packages/akiradocs/compiled/manifest.json | 42 ++++++++++++++ packages/akiradocs/public/context/en_docs.txt | 2 +- .../app/[locale]/[type]/[...slug]/page.tsx | 2 +- packages/akiradocs/src/app/aiSearch/page.tsx | 7 +++ .../akiradocs/src/app/apiReference/page.tsx | 2 +- .../src/components/layout/Header.tsx | 56 ++++++++++--------- packages/akiradocs/src/types/config.ts | 1 + packages/create-app/package.json | 2 +- 8 files changed, 85 insertions(+), 29 deletions(-) create mode 100644 packages/akiradocs/compiled/manifest.json diff --git a/packages/akiradocs/compiled/manifest.json b/packages/akiradocs/compiled/manifest.json new file mode 100644 index 0000000..9b82fb7 --- /dev/null +++ b/packages/akiradocs/compiled/manifest.json @@ -0,0 +1,42 @@ +{ + "files": [ + ".DS_Store", + "de/.DS_Store", + "de/api/apiSpec.json", + "de/articles/_meta.json", + "de/articles/ai_integration.json", + "de/articles/template.json", + "de/articles/welcome.json", + "de/docs/_meta.json", + "de/docs/getting-started/quickstart.json", + "de/docs/introduction.json", + "en/.DS_Store", + "en/api/apiSpec.json", + "en/articles/_meta.json", + "en/articles/ai_integration.json", + "en/articles/template.json", + "en/articles/welcome.json", + "en/docs/_meta.json", + "en/docs/getting-started/quickstart.json", + "en/docs/guides/analytics.json", + "en/docs/introduction.json", + "es/.DS_Store", + "es/api/apiSpec.json", + "es/articles/_meta.json", + "es/articles/ai_integration.json", + "es/articles/template.json", + "es/articles/welcome.json", + "es/docs/_meta.json", + "es/docs/getting-started/quickstart.json", + "es/docs/introduction.json", + "fr/.DS_Store", + "fr/api/apiSpec.json", + "fr/articles/_meta.json", + "fr/articles/ai_integration.json", + "fr/articles/template.json", + "fr/articles/welcome.json", + "fr/docs/_meta.json", + "fr/docs/getting-started/quickstart.json", + "fr/docs/introduction.json" + ] +} \ No newline at end of file diff --git a/packages/akiradocs/public/context/en_docs.txt b/packages/akiradocs/public/context/en_docs.txt index c52da6a..6320cf6 100644 --- a/packages/akiradocs/public/context/en_docs.txt +++ b/packages/akiradocs/public/context/en_docs.txt @@ -22,7 +22,7 @@ Getting Started: Start by customizing this template to match your project's need [Document: articles/template.json] Title: Test Blog Post A test blog post to demonstrate all block types. -Example Heading Sample1 +Example Heading This paragraph is part of the test blog post. It demonstrates the paragraph block. Code example: console.log('Testing all blocks'); diff --git a/packages/akiradocs/src/app/[locale]/[type]/[...slug]/page.tsx b/packages/akiradocs/src/app/[locale]/[type]/[...slug]/page.tsx index 4111dac..bfea903 100644 --- a/packages/akiradocs/src/app/[locale]/[type]/[...slug]/page.tsx +++ b/packages/akiradocs/src/app/[locale]/[type]/[...slug]/page.tsx @@ -113,7 +113,7 @@ export default async function ContentPage({ params }: Props) { description={pageDescription} canonical={canonicalUrl} /> -
+
diff --git a/packages/akiradocs/src/app/aiSearch/page.tsx b/packages/akiradocs/src/app/aiSearch/page.tsx index a620cdf..5e849e3 100644 --- a/packages/akiradocs/src/app/aiSearch/page.tsx +++ b/packages/akiradocs/src/app/aiSearch/page.tsx @@ -15,6 +15,8 @@ import { getAkiradocsConfig } from '@/lib/getAkiradocsConfig' import { ChatCompletionMessageParam, CreateMLCEngine } from "@mlc-ai/web-llm"; import { Source } from '@/types/Source' import AILoader from '@/components/aiSearch/AILoader' +import { getHeaderConfig } from '@/lib/headerConfig' +import { Header } from '@/components/layout/Header' export default function Home() { const [query, setQuery] = useState('') @@ -23,6 +25,7 @@ export default function Home() { const [error, setError] = useState(null) const recommendedArticles = getRecommendedArticles() const searchConfig = getSearchConfig() + const headerConfig = getHeaderConfig() const config = getAkiradocsConfig() const [sources, setSources] = useState([]) @@ -160,7 +163,10 @@ export default function Home() { } return ( +
+
+
+
) } diff --git a/packages/akiradocs/src/app/apiReference/page.tsx b/packages/akiradocs/src/app/apiReference/page.tsx index e36f59c..d1c34ff 100644 --- a/packages/akiradocs/src/app/apiReference/page.tsx +++ b/packages/akiradocs/src/app/apiReference/page.tsx @@ -312,7 +312,7 @@ export default function Page() { }>
-
+
diff --git a/packages/akiradocs/src/components/layout/Header.tsx b/packages/akiradocs/src/components/layout/Header.tsx index 56a363a..ba1bc04 100644 --- a/packages/akiradocs/src/components/layout/Header.tsx +++ b/packages/akiradocs/src/components/layout/Header.tsx @@ -34,7 +34,8 @@ export const Header = memo(function Header({ navItems, socialLinks, languages, - currentLocale = 'en' + currentLocale = 'en', + currentType = 'docs' }: HeaderConfig) { const [isMounted, setIsMounted] = useState(false) const { theme, setTheme } = useTheme() @@ -104,31 +105,36 @@ export const Header = memo(function Header({ // Memoize the navigation items const navigationItems = useMemo(() => { - return navItems?.filter((item) => item.show).map((item, index) => ( - - item.show).map((item, index) => { + // Check if the current nav item matches the page type + const isActive = currentType ? item.href.includes(`/${currentType}`) : pathname === item.href; + + return ( + - {t(item.label as string)} - - - - )) - }, [navItems, pathname]) + + {t(item.label as string)} + + + + ); + }); + }, [navItems, pathname, currentType]); return (