Skip to content

Commit 9faa989

Browse files
committed
main 🧊 new doc template
1 parent d0090be commit 9faa989

156 files changed

Lines changed: 4342 additions & 163 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
pnpm lint-staged
3+
pnpm -r --workspace-concurrency=1 run lint-staged
44

55
if git diff --quiet HEAD -- packages/core; then
66
echo "No changes in packages/core. Skipping build."

packages/core/src/hooks/useClickOutside/useClickOutside.demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cn } from '../../../../docs/lib/utils';
1+
import { cn } from '@siberiacancode/docs/utils';
22
import { useClickOutside, useCounter } from '@siberiacancode/reactuse';
33

44
const Demo = () => {

packages/core/src/hooks/useIdle/useIdle.demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cn } from '../../../../docs/lib/utils';
1+
import { cn } from '@siberiacancode/docs/utils';
22
import { useIdle } from '@siberiacancode/reactuse';
33

44
const Demo = () => {

packages/core/src/hooks/useMergedRef/useMergedRef.demo.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cn } from '@siberiacancode/docs/utils';
12
import {
23
useClickOutside,
34
useCounter,
@@ -7,8 +8,6 @@ import {
78
} from '@siberiacancode/reactuse';
89
import { useRef } from 'react';
910

10-
import { cn } from '../../../../docs/lib/utils';
11-
1211
const Demo = () => {
1312
const counter = useCounter();
1413

packages/core/src/hooks/useMouse/useMouse.demo.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
import { cn } from '@siberiacancode/docs/utils';
12
import { useHover, useMouse } from '@siberiacancode/reactuse';
23
import { useRef } from 'react';
34

4-
import { cn } from '../../../../docs/lib/utils';
5-
65
const Demo = () => {
76
const modalRef = useRef<HTMLDivElement>(null);
87
const mouse = useMouse<HTMLDivElement>((value) => {

packages/core/src/hooks/usePointerLock/usePointerLock.demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CSSProperties } from 'react';
22

3-
import { cn } from '../../../../docs/lib/utils';
3+
import { cn } from '@siberiacancode/docs/utils';
44
import { useEventListener, usePointerLock } from '@siberiacancode/reactuse';
55
import { useRef } from 'react';
66

packages/core/src/hooks/useSticky/useSticky.demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cn } from '../../../../docs/lib/utils';
1+
import { cn } from '@siberiacancode/docs/utils';
22
import { useSticky } from '@siberiacancode/reactuse';
33
import { useRef } from 'react';
44

packages/core/src/hooks/useToggle/useToggle.demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cn } from '../../../../docs/lib/utils';
1+
import { cn } from '@siberiacancode/docs/utils';
22
import { useToggle } from '@siberiacancode/reactuse';
33

44
const Demo = () => {

packages/docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages/core/README.md
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
import type { DefaultTheme, MarkdownOptions } from 'vitepress';
2+
3+
import { transformerTwoslash } from '@shikijs/vitepress-twoslash';
4+
import tailwindcss from '@tailwindcss/vite';
5+
import { fileURLToPath } from 'node:url';
6+
import { defineConfig } from 'vitepress';
7+
8+
import { getContentItems } from '../../src/utils';
9+
10+
export default async () => {
11+
const contentItems = await getContentItems();
12+
const sidebarContentItems = contentItems.reduce<DefaultTheme.SidebarItem[]>(
13+
(categoryItems, contentItem) => {
14+
const category = categoryItems.find((group) => group.text === contentItem.category);
15+
16+
if (!category) {
17+
categoryItems.push({
18+
text: contentItem.category,
19+
items: [contentItem]
20+
});
21+
} else {
22+
category.items!.push(contentItem);
23+
}
24+
25+
return categoryItems;
26+
},
27+
[]
28+
);
29+
30+
return defineConfig({
31+
base: '/',
32+
title: 'reactuse',
33+
titleTemplate: false,
34+
cleanUrls: true,
35+
sitemap: {
36+
hostname: 'https://reactuse.org'
37+
},
38+
description:
39+
'Improve your react applications with our library 📦 designed for comfort and speed',
40+
markdown: {
41+
codeTransformers: [
42+
transformerTwoslash({
43+
twoslashOptions: {
44+
compilerOptions: {
45+
ignoreDeprecations: '6.0'
46+
}
47+
}
48+
})
49+
],
50+
languages: ['js', 'jsx', 'ts', 'tsx']
51+
} as unknown as MarkdownOptions,
52+
vite: {
53+
plugins: [tailwindcss()],
54+
resolve: {
55+
alias: {
56+
'@siberiacancode/reactuse': fileURLToPath(new URL('../../../core/src', import.meta.url)),
57+
'@siberiacancode/docs': fileURLToPath(new URL('../../src', import.meta.url)),
58+
'@': fileURLToPath(new URL('../../../core/src', import.meta.url))
59+
}
60+
}
61+
},
62+
transformPageData: (pageData) => {
63+
pageData.frontmatter.head ??= [];
64+
pageData.frontmatter.head.push([
65+
'meta',
66+
{
67+
name: 'og:image',
68+
content:
69+
'https://repository-images.githubusercontent.com/799880708/0afee0cb-ca48-40a2-9c38-dc5b64ebdf65'
70+
}
71+
]);
72+
73+
if (pageData.relativePath.includes('hooks') && pageData.params?.name) {
74+
const name = pageData.params.name as string;
75+
const description = (pageData.params.description as string) ?? '';
76+
77+
pageData.title = `${name} React hook Reactuse`;
78+
pageData.description = description;
79+
80+
pageData.frontmatter.head.push(
81+
['meta', { property: 'og:title', content: pageData.title }],
82+
['meta', { property: 'og:description', content: pageData.description }]
83+
);
84+
}
85+
},
86+
head: [
87+
['meta', { name: 'algolia-site-verification', content: '60FB6E25551CE504' }],
88+
['link', { rel: 'icon', href: '/favicon.ico' }],
89+
['link', { rel: 'manifest', href: '/manifest.json' }],
90+
[
91+
'script',
92+
{ type: 'text/javascript' },
93+
`(function(m,e,t,r,i,k,a){
94+
m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
95+
m[i].l=1*new Date();
96+
for (var j = 0; j < document.scripts.length; j++) {
97+
if (document.scripts[j].src === r) { return; }
98+
}
99+
k=e.createElement(t),a=e.getElementsByTagName(t)[0],
100+
k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
101+
})(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
102+
103+
ym(102942267, "init", {
104+
clickmap:true,
105+
trackLinks:true,
106+
accurateTrackBounce:true
107+
});`
108+
],
109+
[
110+
'noscript',
111+
{},
112+
`<div><img src="https://mc.yandex.ru/watch/102942267" style="position:absolute; left:-9999px;" alt="" /></div>`
113+
],
114+
115+
[
116+
'script',
117+
{},
118+
`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
119+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
120+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
121+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
122+
})(window,document,'script','dataLayer','GTM-5SMCHX9Z');`
123+
],
124+
125+
[
126+
'script',
127+
{
128+
async: '',
129+
src: 'https://www.googletagmanager.com/gtag/js?id=G-RRECQP6XBW'
130+
}
131+
],
132+
133+
[
134+
'script',
135+
{},
136+
`window.dataLayer = window.dataLayer || [];
137+
function gtag(){dataLayer.push(arguments);}
138+
gtag('js', new Date());
139+
gtag('config', 'G-RRECQP6XBW', {
140+
anonymize_ip: true,
141+
client_storage: 'none',
142+
allow_google_signals: false,
143+
allow_ad_personalization_signals: false
144+
});`
145+
]
146+
],
147+
locales: {
148+
root: {
149+
label: 'English',
150+
lang: 'en',
151+
themeConfig: {
152+
logo: {
153+
src: '/logo.svg',
154+
alt: 'reactuse'
155+
},
156+
footer: {
157+
message: 'Released under the MIT License.',
158+
copyright: `Copyright © ${new Date().getFullYear()} siberiacancode`
159+
},
160+
editLink: {
161+
pattern: ({ filePath, params }) => {
162+
if (filePath.includes('hooks') && params?.name) {
163+
return `https://github.com/siberiacancode/reactuse/blob/main/packages/core/src/hooks/${params.name}/${params.name}.ts`;
164+
} else {
165+
return `https://github.com/siberiacancode/reactuse/blob/main/packages/docs/app/${filePath}`;
166+
}
167+
},
168+
text: 'Suggest changes to this page'
169+
},
170+
nav: [
171+
{ text: 'Home', link: '/' },
172+
{
173+
text: 'Functions',
174+
items: [
175+
{ text: 'Get Started', link: '/introduction' },
176+
{ text: 'Installation', link: '/installation' },
177+
{ text: 'Hooks', link: '/functions/hooks/useAsync.html' }
178+
]
179+
}
180+
],
181+
sidebar: [
182+
{
183+
text: 'Getting started',
184+
items: [
185+
{ text: 'Introduction', link: '/introduction' },
186+
{ text: 'Installation', link: '/installation' },
187+
{ text: 'reactuse.json', link: '/reactuse-json' },
188+
{ text: 'CLI', link: '/cli' },
189+
{ text: 'target', link: '/target' },
190+
{ text: 'memoization', link: '/memoization' },
191+
{ text: 'optimization', link: '/optimization' }
192+
]
193+
},
194+
{
195+
text: 'Installation',
196+
items: [
197+
{ text: 'Vite', link: '/installation/vite' },
198+
{ text: 'Next.js', link: '/installation/nextjs' },
199+
{ text: 'Astro', link: '/installation/astro' },
200+
{ text: 'React Router', link: '/installation/react-router' },
201+
{
202+
text: 'TanStack Router',
203+
link: '/installation/tanstack-router'
204+
},
205+
{ text: 'TanStack Start', link: '/installation/tanstack' },
206+
{ text: 'Preact', link: '/installation/preact' },
207+
{ text: 'Manual', link: '/installation/manual' }
208+
]
209+
},
210+
...sidebarContentItems
211+
]
212+
}
213+
}
214+
// ru: {
215+
// label: 'Русский',
216+
// lang: 'ru',
217+
// themeConfig: {
218+
// nav: [
219+
// { text: 'Главная', link: '/ru' },
220+
// {
221+
// text: 'Функции',
222+
// items: [{ text: 'Хуки', link: '/ru/functions/hooks' }]
223+
// }
224+
// ]
225+
// }
226+
// }
227+
},
228+
themeConfig: {
229+
search: {
230+
provider: 'algolia',
231+
options: {
232+
appId: '62LROXAB1F',
233+
apiKey: '87ab8dd07b4aba02814c082d98e4b8a7',
234+
indexName: 'reactuse'
235+
}
236+
},
237+
socialLinks: [
238+
{ icon: 'github', link: 'https://github.com/siberiacancode/reactuse' },
239+
{
240+
icon: 'npm',
241+
link: 'https://www.npmjs.com/package/@siberiacancode/reactuse'
242+
}
243+
]
244+
}
245+
});
246+
};

0 commit comments

Comments
 (0)