Skip to content

Commit

Permalink
feat: align header links with docs restructure (#103)
Browse files Browse the repository at this point in the history
Aligns links in the header with
matter-labs/zksync-docs#278

This is done through a hack to avoid the need to change nuxt template,
publish new version, and then update the dep. We can do that as a
follow-up.
  • Loading branch information
popzxc authored Dec 6, 2024
1 parent dc8f807 commit ebf2753
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { headerLinks } from './header-links';
provideHeadlessUseId(() => useId());
const { seo } = useAppConfig();
Expand Down Expand Up @@ -37,7 +39,8 @@ defineOgImageComponent('OgImageZK');
<div>
<NuxtLoadingIndicator />

<HeaderComponent />
<!-- FIXME: Hack, we want to pass computed property while `useHeaderNav` expects an array -->
<HeaderComponent :links="computed(() => headerLinks()) as any" />

<UMain>
<NuxtLayout>
Expand Down
4 changes: 3 additions & 1 deletion error.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { headerLinks } from './header-links';
import type { NuxtError } from '#app';
useSeoMeta({
Expand Down Expand Up @@ -26,7 +27,8 @@ provide('navigation', navigation);

<template>
<div>
<HeaderComponent />
<!-- FIXME: Hack, we want to pass computed property while `useHeaderNav` expects an array -->
<HeaderComponent :links="computed(() => headerLinks()) as any" />

<UMain>
<UContainer>
Expand Down
31 changes: 31 additions & 0 deletions header-links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const headerLinks = () => {
const config = useRuntimeConfig();
const route = useRoute();

const activeApp = config.public.app;
const isDocsApp = activeApp === 'docs';
const isCodeApp = activeApp === 'code';

return [
{
label: 'ZKsync Era',
to: isDocsApp ? '/zksync-era' : `${config.public.urls.docs}/zksync-era`,
active: route.path.startsWith('/zksync-era'),
},
{
label: 'ZK Stack',
to: isDocsApp ? '/zk-stack' : `${config.public.urls.docs}/zk-stack`,
active: route.path.startsWith('/zk-stack'),
},
{
label: 'ZKsync Protocol',
to: isDocsApp ? '/zksync-protocol' : `${config.public.urls.docs}/zksync-protocol`,
active: route.path.startsWith('/zksync-protocol'),
},
{
label: 'Community Code',
to: isCodeApp ? '/' : `${config.public.urls.code}`,
active: isCodeApp,
},
];
};

0 comments on commit ebf2753

Please sign in to comment.