Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 01f4aa4

Browse files
committed
feat: highlight the header based on the page you are at
1 parent 9d3343e commit 01f4aa4

File tree

8 files changed

+85
-29
lines changed

8 files changed

+85
-29
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"files": [
3+
".DS_Store",
4+
"de/.DS_Store",
5+
"de/api/apiSpec.json",
6+
"de/articles/_meta.json",
7+
"de/articles/ai_integration.json",
8+
"de/articles/template.json",
9+
"de/articles/welcome.json",
10+
"de/docs/_meta.json",
11+
"de/docs/getting-started/quickstart.json",
12+
"de/docs/introduction.json",
13+
"en/.DS_Store",
14+
"en/api/apiSpec.json",
15+
"en/articles/_meta.json",
16+
"en/articles/ai_integration.json",
17+
"en/articles/template.json",
18+
"en/articles/welcome.json",
19+
"en/docs/_meta.json",
20+
"en/docs/getting-started/quickstart.json",
21+
"en/docs/guides/analytics.json",
22+
"en/docs/introduction.json",
23+
"es/.DS_Store",
24+
"es/api/apiSpec.json",
25+
"es/articles/_meta.json",
26+
"es/articles/ai_integration.json",
27+
"es/articles/template.json",
28+
"es/articles/welcome.json",
29+
"es/docs/_meta.json",
30+
"es/docs/getting-started/quickstart.json",
31+
"es/docs/introduction.json",
32+
"fr/.DS_Store",
33+
"fr/api/apiSpec.json",
34+
"fr/articles/_meta.json",
35+
"fr/articles/ai_integration.json",
36+
"fr/articles/template.json",
37+
"fr/articles/welcome.json",
38+
"fr/docs/_meta.json",
39+
"fr/docs/getting-started/quickstart.json",
40+
"fr/docs/introduction.json"
41+
]
42+
}

packages/akiradocs/public/context/en_docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Getting Started: Start by customizing this template to match your project's need
2222
[Document: articles/template.json]
2323
Title: Test Blog Post
2424
A test blog post to demonstrate all block types.
25-
Example Heading Sample1
25+
Example Heading
2626
This paragraph is part of the test blog post. It demonstrates the paragraph block.
2727
Code example:
2828
console.log('Testing all blocks');

packages/akiradocs/src/app/[locale]/[type]/[...slug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default async function ContentPage({ params }: Props) {
113113
description={pageDescription}
114114
canonical={canonicalUrl}
115115
/>
116-
<Header {...headerConfig} currentLocale={locale} />
116+
<Header {...headerConfig} currentLocale={locale} currentType={`${locale}/${type}`}/>
117117
<div className="flex flex-grow">
118118
<Navigation key={type} locale={locale} items={navigationItems} />
119119
<div className="flex-1 flex py-4 w-full">

packages/akiradocs/src/app/aiSearch/page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { getAkiradocsConfig } from '@/lib/getAkiradocsConfig'
1515
import { ChatCompletionMessageParam, CreateMLCEngine } from "@mlc-ai/web-llm";
1616
import { Source } from '@/types/Source'
1717
import AILoader from '@/components/aiSearch/AILoader'
18+
import { getHeaderConfig } from '@/lib/headerConfig'
19+
import { Header } from '@/components/layout/Header'
1820

1921
export default function Home() {
2022
const [query, setQuery] = useState('')
@@ -23,6 +25,7 @@ export default function Home() {
2325
const [error, setError] = useState<string | null>(null)
2426
const recommendedArticles = getRecommendedArticles()
2527
const searchConfig = getSearchConfig()
28+
const headerConfig = getHeaderConfig()
2629
const config = getAkiradocsConfig()
2730
const [sources, setSources] = useState<Source[]>([])
2831

@@ -160,7 +163,10 @@ export default function Home() {
160163
}
161164

162165
return (
166+
<div className="flex flex-col min-h-screen">
167+
<Header {...headerConfig} currentLocale={`en`} currentType={`aiSearch`}/>
163168
<div className="min-h-screen py-12 px-4 sm:px-6 lg:px-8">
169+
164170
<div className="max-w-4xl mx-auto">
165171
<SearchHeader
166172
logo={searchConfig.logo}
@@ -201,5 +207,6 @@ export default function Home() {
201207
</AnimatePresence>
202208
</div>
203209
</div>
210+
</div>
204211
)
205212
}

packages/akiradocs/src/app/apiReference/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export default function Page() {
312312
<Suspense fallback={<LoadingSpinner />}>
313313

314314
<div className="flex flex-col min-h-screen">
315-
<Header {...headerConfig} currentLocale={locale} />
315+
<Header {...headerConfig} currentLocale={locale} currentType={`en/apiReference`}/>
316316
<div className="flex flex-1">
317317
<ApiSidebar />
318318
<main className="flex-1 h-full overflow-y-auto pt-6 px-6">

packages/akiradocs/src/components/layout/Header.tsx

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export const Header = memo(function Header({
3434
navItems,
3535
socialLinks,
3636
languages,
37-
currentLocale = 'en'
37+
currentLocale = 'en',
38+
currentType = 'docs'
3839
}: HeaderConfig) {
3940
const [isMounted, setIsMounted] = useState(false)
4041
const { theme, setTheme } = useTheme()
@@ -104,31 +105,36 @@ export const Header = memo(function Header({
104105

105106
// Memoize the navigation items
106107
const navigationItems = useMemo(() => {
107-
return navItems?.filter((item) => item.show).map((item, index) => (
108-
<motion.div
109-
key={index}
110-
initial={{ opacity: 0, y: -20 }}
111-
animate={{ opacity: 1, y: 0 }}
112-
exit={{ opacity: 0, y: -20 }}
113-
transition={{ delay: index * 0.1 }}
114-
>
115-
<Link
116-
href={item.href}
117-
className={`group relative flex items-center gap-x-2 text-sm font-medium transition-colors px-3 py-2 rounded-md
118-
${pathname === item.href
119-
? 'text-foreground bg-muted'
120-
: 'text-muted-foreground hover:text-foreground'
121-
}`}
108+
return navItems?.filter((item) => item.show).map((item, index) => {
109+
// Check if the current nav item matches the page type
110+
const isActive = currentType ? item.href.includes(`/${currentType}`) : pathname === item.href;
111+
112+
return (
113+
<motion.div
114+
key={index}
115+
initial={{ opacity: 0, y: -20 }}
116+
animate={{ opacity: 1, y: 0 }}
117+
exit={{ opacity: 0, y: -20 }}
118+
transition={{ delay: index * 0.1 }}
122119
>
123-
{t(item.label as string)}
124-
<span
125-
className={`absolute inset-x-0 -bottom-px h-0.5 bg-primary transition-transform duration-150 ease-in-out
126-
${pathname === item.href ? 'scale-x-100' : 'scale-x-0 group-hover:scale-x-100'}`}
127-
/>
128-
</Link>
129-
</motion.div>
130-
))
131-
}, [navItems, pathname])
120+
<Link
121+
href={item.href}
122+
className={`group relative flex items-center gap-x-2 text-sm font-medium transition-colors px-3 py-2 rounded-md
123+
${isActive
124+
? 'text-foreground bg-muted'
125+
: 'text-muted-foreground hover:text-foreground'
126+
}`}
127+
>
128+
{t(item.label as string)}
129+
<span
130+
className={`absolute inset-x-0 -bottom-px h-0.5 bg-primary transition-transform duration-150 ease-in-out
131+
${isActive ? 'scale-x-100' : 'scale-x-0 group-hover:scale-x-100'}`}
132+
/>
133+
</Link>
134+
</motion.div>
135+
);
136+
});
137+
}, [navItems, pathname, currentType]);
132138

133139
return (
134140
<motion.header

packages/akiradocs/src/types/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interface NavItem {
3939
}[];
4040
};
4141
currentLocale?: string;
42+
currentType?: string;
4243
}
4344

4445
export interface FooterConfig {

packages/create-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-akiradocs",
3-
"version": "1.0.51",
3+
"version": "1.0.52",
44
"description": "Create Akira Docs documentation sites with one command",
55
"main": "./dist/index.js",
66
"type": "module",

0 commit comments

Comments
 (0)