Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update layout for algolia search #50

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
23 changes: 23 additions & 0 deletions composables/useCategory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const defaultCategory = 'Community Code';

// Order by most specific to least specific.
// e.g. `/js/ethers/api/v5` before `/js/ethers`
const categories = [['/tutorials', 'Community Code Guides']] as const;

/**
* Returns the category of the current route.
* Primarily this is for the algolia docsearch
*/
export const useCategory = () => {
const route = useRoute();
const category = ref(defaultCategory);
// for if we ever have i18n routes, remove the language prefix
// const langAgnosticPath = route.path.replace(/\/\w\w(-\w\w)?\//, '');
for (const [path, label] of categories) {
if (route.path.startsWith(path)) {
category.value = label;
break;
}
}
return category;
};
4 changes: 2 additions & 2 deletions content/tutorials/native-aa-multisig/10.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,8 @@ export default async function (hre: HardhatRuntimeEnvironment) {

::callout{icon="i-heroicons-light-bulb"}
ZKsync has different address derivation rules from Ethereum.
Always use the [`createAddress`](https://sdk.zksync.io/js/ethers/api/v6/utilities/utils#createaddress)
and [`create2Address`](https://sdk.zksync.io/js/ethers/api/v6/utilities/utils#create2address) utility functions of the `zksync-ethers` SDK.
Always use the [`createAddress`](https://sdk.zksync.io/js/ethers/api/v6/utilities#createaddress)
and [`create2Address`](https://sdk.zksync.io/js/ethers/api/v6/utilities#create2address) utility functions of the `zksync-ethers` SDK.
itsacoyote marked this conversation as resolved.
Show resolved Hide resolved

Read the documentation for more information on [address derivation differences between Ethereum and ZKsync](https://docs.zksync.io/build/developer-reference/ethereum-differences/evm-instructions#address-derivation).
::
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"release": "semantic-release"
},
"dependencies": {
"@matterlabs/docs-nuxt-template": "2.7.0",
"@matterlabs/docs-nuxt-template": "2.7.1",
"@nuxt/content": "^2.13.2",
"@nuxt/eslint": "^0.3.13",
"@nuxt/eslint": "^0.5.3",
"@nuxt/fonts": "^0.5.1",
"@nuxt/image": "^1.7.0",
"@nuxt/ui": "^2.18.4",
Expand Down
4 changes: 2 additions & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ useSeoMeta({
<AuthorsList :authors="guide.authors" />
<div class="mt-2">
<UBadge
v-for="(tag, index) of guide.tags"
:key="index"
v-for="(tag, tagIndex) of guide.tags"
:key="tagIndex"
:label="tag"
color="blue"
size="xs"
Expand Down
256 changes: 134 additions & 122 deletions pages/tutorials/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ definePageMeta({

const route = useRoute();
const nav = inject<Ref<NavItem[]>>('navigation');
const category = useCategory();

const metadata = computed(() => {
return nav?.value
.find((item) => item._path === '/tutorials')
?.children?.find((item) => item._path === `/tutorials/${route.params.slug[0]}`);
?.children?.find((item: { _path: string }) => item._path === `/tutorials/${route.params.slug[0]}`);
});
const isIndex = ref(route.params.slug.length < 2);

Expand Down Expand Up @@ -65,7 +66,7 @@ const links = [
{
label: metadata.value?.title || 'Guide',
collapsible: false,
children: metadata.value?.children?.map((item) => ({
children: metadata.value?.children?.map((item: { title: string; _path: string }) => ({
label: item.title,
to: item._path,
})),
Expand Down Expand Up @@ -109,135 +110,146 @@ const communityLinks = [
<UPageLinks :links="communityLinks" />
</UAside>
</template>

<UPage v-if="isIndex && metadata">
<UPageHeader
:title="page?.title"
:description="page?.description"
/>
<div class="grid grid-cols-8 gap-4 py-5">
<div class="col-span-5">
<AuthorsList
class="mb-4"
:authors="metadata.authors"
:with-links="true"
/>
<p>
{{ metadata.description }}
</p>
<template v-if="metadata.what_you_will_learn">
<h3 class="mt-4 text-xl font-semibold">What you'll learn:</h3>
<ul
role="list"
class="mt-2 list-inside list-disc space-y-1"
>
<li
v-for="item in metadata.what_you_will_learn"
:key="item"
<article>
<span
id="docsearch-lv0"
hidden
>{{ category }}</span
>
<span
id="docsearch-lv1"
hidden
>{{ metadata?.title }}: {{ page?.title }}</span
>
<UPage v-if="isIndex && metadata">
<UPageHeader
:title="page?.title"
:description="page?.description"
/>
<div class="grid grid-cols-8 gap-4 py-5">
<div class="col-span-5">
<AuthorsList
class="mb-4"
:authors="metadata.authors"
:with-links="true"
/>
<p>
{{ metadata.description }}
</p>
<template v-if="metadata.what_you_will_learn">
<h3 class="mt-4 text-xl font-semibold">What you'll learn:</h3>
<ul
role="list"
class="mt-2 list-inside list-disc space-y-1"
>
{{ item }}
</li>
</ul>
</template>
</div>

<div class="col-span-3">
<UButton
v-if="metadata.github_repo"
icon="i-simple-icons-github"
size="sm"
color="white"
variant="solid"
label="GitHub"
target="_blank"
:to="metadata.github_repo"
:trailing="false"
/>
<template v-if="metadata.tools">
<h3 class="my-2 text-lg font-semibold">Tools:</h3>
<ul
role="list"
class="list-inside list-none"
>
<li
v-for="item in metadata.tools"
:key="item"
<li
v-for="item in metadata.what_you_will_learn"
:key="item"
>
{{ item }}
</li>
</ul>
</template>
</div>

<div class="col-span-3">
<UButton
v-if="metadata.github_repo"
icon="i-simple-icons-github"
size="sm"
color="white"
variant="solid"
label="GitHub"
target="_blank"
:to="metadata.github_repo"
:trailing="false"
/>
<template v-if="metadata.tools">
<h3 class="my-2 text-lg font-semibold">Tools:</h3>
<ul
role="list"
class="list-inside list-none"
>
- {{ item }}
</li>
</ul>
</template>
<template v-if="metadata.tags">
<div class="mt-4 flex flex-wrap">
<UBadge
v-for="tag in metadata.tags"
:key="tag"
:label="tag"
color="blue"
size="sm"
variant="subtle"
class="mb-2 mr-2"
/>
</div>
</template>
<template v-if="metadata.updated">
<strong class="text-md my-2">Last Updated: </strong>{{ lastUpdated }}
</template>
<li
v-for="item in metadata.tools"
:key="item"
>
- {{ item }}
</li>
</ul>
</template>
<template v-if="metadata.tags">
<div class="mt-4 flex flex-wrap">
<UBadge
v-for="tag in metadata.tags"
:key="tag"
:label="tag"
color="blue"
size="sm"
variant="subtle"
class="mb-2 mr-2"
/>
</div>
</template>
<template v-if="metadata.updated">
<strong class="text-md my-2">Last Updated: </strong>{{ lastUpdated }}
</template>
</div>
</div>
</div>
<UDivider icon="i-zkicon-zksync" />
</UPage>

<UPage>
<UPageHeader
v-if="!isIndex"
:title="page?.title"
:description="page?.description"
/>

<UPageBody prose>
<ContentRenderer
v-if="page?.body"
:value="page"
<UDivider icon="i-zkicon-zksync" />
</UPage>

<UPage>
<UPageHeader
v-if="!isIndex"
:title="page?.title"
:description="page?.description"
/>

<hr
v-if="surround.length > 0"
class="mb-4"
/>
<UPageBody prose>
<ContentRenderer
v-if="page?.body"
:value="page"
/>

<UContentSurround
:surround
:ui="{
wrapper: 'grid gap-8 sm:grid-cols-2',
icon: {
prev: 'i-heroicons-arrow-left-20-solid',
next: 'i-heroicons-arrow-right-20-solid',
},
link: {
wrapper:
'block px-3 py-4 border not-prose rounded-lg border-gray-200 dark:border-gray-800 hover:bg-gray-100/50 dark:hover:bg-gray-800/50 group flex gap-4 items-center even:flex-row-reverse',
<hr
v-if="surround.length > 0"
class="mb-4"
/>

<UContentSurround
:surround
:ui="{
wrapper: 'grid gap-8 sm:grid-cols-2',
icon: {
prev: 'i-heroicons-arrow-left-20-solid',
next: 'i-heroicons-arrow-right-20-solid',
},
link: {
wrapper:
'mb-0 inline-flex items-center rounded-full p-1.5 bg-gray-100 dark:bg-gray-800 group-hover:bg-primary/10 ring-1 ring-gray-300 dark:ring-gray-700 group-hover:ring-primary/50',
'block px-3 py-4 border not-prose rounded-lg border-gray-200 dark:border-gray-800 hover:bg-gray-100/50 dark:hover:bg-gray-800/50 group flex gap-4 items-center even:flex-row-reverse',
icon: {
wrapper:
'mb-0 inline-flex items-center rounded-full p-1.5 bg-gray-100 dark:bg-gray-800 group-hover:bg-primary/10 ring-1 ring-gray-300 dark:ring-gray-700 group-hover:ring-primary/50',
},
title: 'font-medium text-gray-900 dark:text-white text-[15px] mb-0',
description: 'display-none',
},
title: 'font-medium text-gray-900 dark:text-white text-[15px] mb-0',
description: 'display-none',
},
}"
/>
</UPageBody>

<template
v-if="page?.toc !== false"
#right
>
<UContentToc
title="Table of contents"
:links="page?.body?.toc?.links"
/>
</template>
</UPage>
}"
/>
</UPageBody>

<template
v-if="page?.toc !== false"
#right
>
<UContentToc
title="Table of contents"
:links="page?.body?.toc?.links"
/>
</template>
</UPage>
</article>
</UPage>
</UContainer>
</template>
2 changes: 1 addition & 1 deletion tests/utils/button.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page } from '@playwright/test';
import type { Page } from '@playwright/test';

export async function clickButtonByText(page: Page, selector: string | RegExp) {
await page.locator('button').getByText(selector).click();
Expand Down
Loading