Skip to content

Commit 221b437

Browse files
committed
main 🧊 update doc
1 parent f87c696 commit 221b437

4 files changed

Lines changed: 33 additions & 6 deletions

File tree

‎packages/docs/app/.vitepress/sections/HomeHooks/HomeHooks.data.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
const hooksWithLinks = await Promise.all(
88
hooks.map(async (hook) => ({
99
...hook,
10-
link: await getHookDocsLink(hook.name)
10+
...(await getHookDocsLink(hook.name))
1111
}))
1212
);
1313

‎packages/docs/app/.vitepress/sections/HomeHooks/HomeHooks.vue‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ const filteredHooks = computed(() =>
1212
return {
1313
name: hook.name,
1414
link: hook.link,
15+
rel: hook.rel,
16+
target: hook.target,
1517
disabled: false
1618
};
1719
1820
return {
1921
name: hook.name,
2022
link: hook.link,
23+
rel: hook.rel,
24+
target: hook.target,
2125
disabled: true
2226
};
2327
})
@@ -58,7 +62,12 @@ const filteredHooks = computed(() =>
5862

5963
<div class="mt-10 flex w-[130%] flex-wrap justify-start gap-3">
6064
<div v-for="hook in filteredHooks.slice(0, 40)" :key="hook.name">
61-
<a :href="hook.link" class="text-2xl text-[var(--vp-c-text-1)]! no-underline!">
65+
<a
66+
:href="hook.link"
67+
:rel="hook.rel"
68+
:target="hook.target"
69+
class="text-2xl text-[var(--vp-c-text-1)]! no-underline!"
70+
>
6271
<div
6372
class="items-center rounded-lg border-[1px] border-transparent bg-[var(--vp-c-default-soft)] px-6 py-2 transition-all duration-200 hover:border-[var(--vp-c-brand-1)]/80 hover:shadow-md"
6473
:class="{

‎packages/docs/src/utils/docs/getContentItems.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ interface ContentItem {
77
category: string;
88
description: string;
99
link: string;
10+
rel?: string;
11+
target?: string;
1012
text: string;
1113
}
1214

@@ -35,11 +37,13 @@ export const getContentItems = async () => {
3537
return null;
3638
}
3739

40+
const navigation = await getHookDocsLink(item.name);
41+
3842
return {
3943
text: item.name,
4044
description: jsdoc.description.description,
4145
category: jsdoc.category?.name,
42-
link: await getHookDocsLink(item.name)
46+
...navigation
4347
};
4448
})
4549
);

‎packages/docs/src/utils/docs/getHookDocsLink.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { readdir } from 'node:fs/promises';
22
import path from 'node:path';
33
import process from 'node:process';
44

5+
const SITE_ORIGIN = 'https://reactuse.org';
6+
57
let migratedHookNamesPromise: Promise<Set<string>> | null = null;
68

79
const getMigratedHookNames = async () => {
@@ -22,12 +24,24 @@ const getMigratedHookNames = async () => {
2224
return migratedHookNamesPromise;
2325
};
2426

25-
export const getHookDocsLink = async (name: string) => {
27+
export interface HookDocsNavigation {
28+
link: string;
29+
rel?: string;
30+
target?: string;
31+
}
32+
33+
export const getHookDocsLink = async (name: string): Promise<HookDocsNavigation> => {
2634
const migratedHookNames = await getMigratedHookNames();
2735

2836
if (migratedHookNames.has(name)) {
29-
return `/new/functions/hooks/${name}`;
37+
return {
38+
link: `${SITE_ORIGIN}/new/functions/hooks/${name}`,
39+
rel: 'noreferrer',
40+
target: '_self'
41+
};
3042
}
3143

32-
return `/functions/hooks/${name}`;
44+
return {
45+
link: `/functions/hooks/${name}`
46+
};
3347
};

0 commit comments

Comments
 (0)