mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
Rename components name
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import NavBar from 'components/NavBar';
|
import NavBar from 'components/nav-bar';
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
|
|
||||||
describe('NavBar', () => {
|
describe('NavBar', () => {
|
@ -1,6 +1,6 @@
|
|||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import PostCard from 'components/PostCard';
|
import PostCard from 'components/post-card';
|
||||||
|
|
||||||
const post = {
|
const post = {
|
||||||
slug: 'first-post',
|
slug: 'first-post',
|
@ -1,5 +1,5 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import Button from 'components/RUA/Button';
|
import Button from 'components/rua/button';
|
||||||
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { FiChevronUp } from 'react-icons/fi';
|
import { FiChevronUp } from 'react-icons/fi';
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import useMounted from 'lib/hooks/useMounted';
|
import useMounted from 'lib/hooks/use-mounted';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { FiMoon, FiSun } from 'react-icons/fi';
|
import { FiMoon, FiSun } from 'react-icons/fi';
|
@ -1,12 +1,12 @@
|
|||||||
import LinkAnchor from 'components/mdx/LinkAnchor';
|
import LinkAnchor from 'components/mdx/link-anchor';
|
||||||
import Loading from 'components/RUA/loading/RUALoading';
|
import Loading from 'components/rua/loading/rua-loading';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { GistData } from 'lib/fetcher';
|
import { GistData } from 'lib/fetcher';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { memo, Suspense } from 'react';
|
import { memo, Suspense } from 'react';
|
||||||
|
|
||||||
const GistsCode = dynamic(() => import('components/gists/GistsCode'), {
|
const GistsCode = dynamic(() => import('components/gists/gists-code'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
@ -7,7 +7,7 @@ import remarkParse from 'remark-parse';
|
|||||||
import remarkRehype from 'remark-rehype';
|
import remarkRehype from 'remark-rehype';
|
||||||
import { GistsFile } from 'types';
|
import { GistsFile } from 'types';
|
||||||
import { unified } from 'unified';
|
import { unified } from 'unified';
|
||||||
import styles from './GistsCode.module.css';
|
import styles from './gists-code.module.css';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
file: GistsFile;
|
file: GistsFile;
|
@ -1,11 +1,11 @@
|
|||||||
import Anchor from 'components/mdx/Anchor';
|
import Anchor from 'components/mdx/anchor';
|
||||||
import Image from 'components/mdx/Image';
|
import Image from 'components/mdx/image';
|
||||||
import Pre from 'components/mdx/Pre';
|
import Pre from 'components/mdx/pre';
|
||||||
import RUACodepen from 'components/RUA/RUACodepen';
|
import RUACodepen from 'components/rua/rua-codepen';
|
||||||
import RUACodeSandbox from 'components/RUA/RUACodeSandbox';
|
import RUACodeSandbox from 'components/rua/rua-code-sandbox';
|
||||||
import RUASandpack from 'components/RUA/RUASandpack';
|
import RUASandpack from 'components/rua/rua-sandpack';
|
||||||
import Tab from 'components/RUA/tab';
|
import Tab from 'components/rua/tab';
|
||||||
import TabItem from 'components/RUA/tab/TabItem';
|
import TabItem from 'components/rua/tab/tab-item';
|
||||||
|
|
||||||
const components = {
|
const components = {
|
||||||
RUASandpack,
|
RUASandpack,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import CopyButton from 'components/post/CopyButton';
|
import CopyButton from 'components/post/copy-button';
|
||||||
import useCopyToClipboard from 'lib/hooks/useCopyToClipboard';
|
import useCopyToClipboard from 'lib/hooks/use-copy-to-clipboard';
|
||||||
import {
|
import {
|
||||||
DetailedHTMLProps,
|
DetailedHTMLProps,
|
||||||
HTMLAttributes,
|
HTMLAttributes,
|
@ -6,7 +6,7 @@ import Link from 'next/link';
|
|||||||
import { memo, useEffect, useState } from 'react';
|
import { memo, useEffect, useState } from 'react';
|
||||||
import { FiMenu } from 'react-icons/fi';
|
import { FiMenu } from 'react-icons/fi';
|
||||||
|
|
||||||
const DarkModeBtn = dynamic(() => import('components/DarkModeBtn'));
|
const DarkModeBtn = dynamic(() => import('components/dark-mode-btn'));
|
||||||
|
|
||||||
const txtMenu = [
|
const txtMenu = [
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { memo, useState } from 'react';
|
import { memo, useState } from 'react';
|
||||||
import styles from './CopytButton.module.css';
|
import styles from './copyt-button.module.css';
|
||||||
|
|
||||||
export type CopyButtonProps = {
|
export type CopyButtonProps = {
|
||||||
className?: string;
|
className?: string;
|
@ -1,9 +1,9 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import Anchor from 'components/mdx/Anchor';
|
import Anchor from 'components/mdx/anchor';
|
||||||
import { SingleToc } from 'lib/utils';
|
import { SingleToc } from 'lib/utils';
|
||||||
import { Fragment, memo, useState } from 'react';
|
import { Fragment, memo, useState } from 'react';
|
||||||
import { FiChevronDown } from 'react-icons/fi';
|
import { FiChevronDown } from 'react-icons/fi';
|
||||||
import styles from './PostToc.module.css';
|
import styles from './post-toc.module.css';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
toc: SingleToc[];
|
toc: SingleToc[];
|
@ -9,7 +9,7 @@ type Props = {
|
|||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const RUALoading = ({ className: classNames }: Props) => {
|
const RuaLoading = ({ className: classNames }: Props) => {
|
||||||
const { systemTheme, theme } = useTheme();
|
const { systemTheme, theme } = useTheme();
|
||||||
const currentTheme = theme === 'system' ? systemTheme : theme;
|
const currentTheme = theme === 'system' ? systemTheme : theme;
|
||||||
|
|
||||||
@ -34,4 +34,4 @@ const RUALoading = ({ className: classNames }: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(RUALoading);
|
export default memo(RuaLoading);
|
@ -1,6 +1,6 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import styles from './VercelLoading.module.css';
|
import styles from './vercel-loading.module.css';
|
||||||
|
|
||||||
const VercelLoading = () => {
|
const VercelLoading = () => {
|
||||||
return (
|
return (
|
@ -1,8 +1,8 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import useInView from 'lib/hooks/useInView';
|
import useInView from 'lib/hooks/use-in-view';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import { memo, useEffect, useState } from 'react';
|
import { memo, useEffect, useState } from 'react';
|
||||||
import RUALoading from './loading/RUALoading';
|
import RUALoading from './loading/rua-loading';
|
||||||
|
|
||||||
const pattern =
|
const pattern =
|
||||||
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/;
|
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/;
|
||||||
@ -15,7 +15,7 @@ type Props = {
|
|||||||
url: string;
|
url: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const RUACodeSandbox = ({ url }: Props) => {
|
const RuaCodeSandbox = ({ url }: Props) => {
|
||||||
const isUrl = pattern.test(url);
|
const isUrl = pattern.test(url);
|
||||||
const { systemTheme, theme } = useTheme();
|
const { systemTheme, theme } = useTheme();
|
||||||
const currentTheme = theme === 'system' ? systemTheme : theme ?? 'light';
|
const currentTheme = theme === 'system' ? systemTheme : theme ?? 'light';
|
||||||
@ -64,4 +64,4 @@ const RUACodeSandbox = ({ url }: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(RUACodeSandbox);
|
export default memo(RuaCodeSandbox);
|
@ -1,8 +1,8 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import useInView from 'lib/hooks/useInView';
|
import useInView from 'lib/hooks/use-in-view';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import { memo, useEffect, useState } from 'react';
|
import { memo, useEffect, useState } from 'react';
|
||||||
import RUALoading from './loading/RUALoading';
|
import RUALoading from './loading/rua-loading';
|
||||||
|
|
||||||
export const commonClass = clsx(
|
export const commonClass = clsx(
|
||||||
'rounded-lg h-[400px] border-0',
|
'rounded-lg h-[400px] border-0',
|
||||||
@ -14,7 +14,7 @@ type Props = {
|
|||||||
url: string;
|
url: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const RUACodepen = ({ defaultTab, url }: Props) => {
|
const RuaCodepen = ({ defaultTab, url }: Props) => {
|
||||||
const urlArr = url.split('/');
|
const urlArr = url.split('/');
|
||||||
const { systemTheme, theme } = useTheme();
|
const { systemTheme, theme } = useTheme();
|
||||||
const currentTheme = theme === 'system' ? systemTheme : theme ?? 'light';
|
const currentTheme = theme === 'system' ? systemTheme : theme ?? 'light';
|
||||||
@ -80,4 +80,4 @@ const RUACodepen = ({ defaultTab, url }: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(RUACodepen);
|
export default memo(RuaCodepen);
|
@ -2,7 +2,7 @@ import dynamic from 'next/dynamic';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { DetailedHTMLProps, HTMLAttributes, memo } from 'react';
|
import { DetailedHTMLProps, HTMLAttributes, memo } from 'react';
|
||||||
|
|
||||||
const Button = dynamic(() => import('components/RUA/Button'));
|
const Button = dynamic(() => import('components/rua/button'));
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
hasPrev: boolean;
|
hasPrev: boolean;
|
||||||
@ -13,7 +13,7 @@ type Props = {
|
|||||||
total?: number;
|
total?: number;
|
||||||
} & DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
} & DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
||||||
|
|
||||||
const RUAPagination = ({
|
const RuaPagination = ({
|
||||||
hasPrev,
|
hasPrev,
|
||||||
hasNext,
|
hasNext,
|
||||||
prevLink,
|
prevLink,
|
||||||
@ -59,4 +59,4 @@ const RUAPagination = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(RUAPagination);
|
export default memo(RuaPagination);
|
@ -4,7 +4,7 @@ import { memo } from 'react';
|
|||||||
|
|
||||||
interface Props extends SandpackProps {}
|
interface Props extends SandpackProps {}
|
||||||
|
|
||||||
const RUASandpack = ({ ...rest }: Props) => {
|
const RuaSandpack = ({ ...rest }: Props) => {
|
||||||
const { systemTheme, theme } = useTheme();
|
const { systemTheme, theme } = useTheme();
|
||||||
const currentTheme = theme === 'system' ? systemTheme : theme;
|
const currentTheme = theme === 'system' ? systemTheme : theme;
|
||||||
|
|
||||||
@ -20,4 +20,4 @@ const RUASandpack = ({ ...rest }: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(RUASandpack);
|
export default memo(RuaSandpack);
|
@ -1,6 +1,6 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import React, { memo, useState } from 'react';
|
import React, { memo, useState } from 'react';
|
||||||
import { ItemProps } from './TabItem';
|
import { ItemProps } from './tab-item';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
defaultValue: string | number;
|
defaultValue: string | number;
|
@ -142,7 +142,7 @@ const Couter = () => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/Input.tsx': {
|
'/Input.tsx': {
|
||||||
@ -242,7 +242,7 @@ const Count = () => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/Input.tsx': {
|
'/Input.tsx': {
|
||||||
@ -373,7 +373,7 @@ export const useTodoStore = (): [Todo, RUADispatch<TodoAction>] => [
|
|||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/Input.tsx': {
|
'/Input.tsx': {
|
||||||
|
@ -22,7 +22,7 @@ tags: [TypeScript, React]
|
|||||||
|
|
||||||
React Hook Forms 对 TypeScript 支持良好,有了 TypeScript 我们就可以在开发时验证表单类型。而表单的数据类型也是后续封装通用组件较为繁琐的一个地方。
|
React Hook Forms 对 TypeScript 支持良好,有了 TypeScript 我们就可以在开发时验证表单类型。而表单的数据类型也是后续封装通用组件较为繁琐的一个地方。
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/App.tsx':
|
'/App.tsx':
|
||||||
@ -207,7 +207,7 @@ const sayIt = <T extends number | string>(p: Person<T>) => {
|
|||||||
|
|
||||||
来看一个简单的小组件,该组件可以以一个常见的对象类型 `Record<string, unknown>` 来根据指定的 key 访问其值,并展示在 DOM 上。
|
来看一个简单的小组件,该组件可以以一个常见的对象类型 `Record<string, unknown>` 来根据指定的 key 访问其值,并展示在 DOM 上。
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/App.tsx':
|
'/App.tsx':
|
||||||
@ -354,4 +354,4 @@ const Input = <T extends Record<string, unknown>>({
|
|||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
<RUACodeSandbox url="https://codesandbox.io/s/reusable-input-o7e4jt?file=/src/App.tsx" />
|
<RuaCodeSandbox url="https://codesandbox.io/s/reusable-input-o7e4jt?file=/src/App.tsx" />
|
||||||
|
@ -14,7 +14,7 @@ console.log('Hello world');
|
|||||||
|
|
||||||
## Say hello to world
|
## Say hello to world
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react"
|
template="react"
|
||||||
files={{
|
files={{
|
||||||
'/App.js': sandpack['hello-world'].hello,
|
'/App.js': sandpack['hello-world'].hello,
|
||||||
|
@ -45,7 +45,7 @@ renderer.render(scene, camera);
|
|||||||
|
|
||||||
Now, we can get a black canvas in our document.
|
Now, we can get a black canvas in our document.
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react"
|
template="react"
|
||||||
files={{
|
files={{
|
||||||
'/App.js': sandpack['how-to-load-a-background-with-threejs'].firstScene,
|
'/App.js': sandpack['how-to-load-a-background-with-threejs'].firstScene,
|
||||||
@ -125,7 +125,7 @@ controls.enablePan = false;
|
|||||||
controls.update();
|
controls.update();
|
||||||
```
|
```
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react"
|
template="react"
|
||||||
files={{
|
files={{
|
||||||
'/App.js': sandpack['how-to-load-a-background-with-threejs'].loadBackground,
|
'/App.js': sandpack['how-to-load-a-background-with-threejs'].loadBackground,
|
||||||
|
@ -291,4 +291,4 @@ window.onload = function () {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<RUACodepen url="https://codepen.io/Defectink/pen/BaLQZZQ" />
|
<RuaCodepen url="https://codepen.io/Defectink/pen/BaLQZZQ" />
|
||||||
|
@ -87,4 +87,4 @@ earth.getWorldPosition(position);
|
|||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
<RUACodeSandbox url="https://codesandbox.io/s/arounding-box-b1g4qq" />
|
<RuaCodeSandbox url="https://codesandbox.io/s/arounding-box-b1g4qq" />
|
||||||
|
@ -26,7 +26,7 @@ tags: [React, TypeScript]
|
|||||||
|
|
||||||
`useTransition` 返回的元组中包含两个值 `[pending, setTransiton]` ,分别是 `setTransiton` 方法和表示正在过渡的状态 `pending` 。如果需要在过渡时展示特定的 UI 就可以使用 `pending` 来控制状态。
|
`useTransition` 返回的元组中包含两个值 `[pending, setTransiton]` ,分别是 `setTransiton` 方法和表示正在过渡的状态 `pending` 。如果需要在过渡时展示特定的 UI 就可以使用 `pending` 来控制状态。
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/Button.tsx': {
|
'/Button.tsx': {
|
||||||
@ -45,7 +45,7 @@ tags: [React, TypeScript]
|
|||||||
|
|
||||||
将原本的状态值 `value` 与 `useDeferredValue` 返回的副本相比较就会发现 `value` 会随着 UI 一起被更新,而被延迟的状态 `deferred` 会等待 UI 更新结束后再做更新。
|
将原本的状态值 `value` 与 `useDeferredValue` 返回的副本相比较就会发现 `value` 会随着 UI 一起被更新,而被延迟的状态 `deferred` 会等待 UI 更新结束后再做更新。
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/Button.tsx': {
|
'/Button.tsx': {
|
||||||
@ -65,7 +65,7 @@ tags: [React, TypeScript]
|
|||||||
- 为页面中需要唯一 ID 元素提供 ID,例如 `<label for="ID">` 。
|
- 为页面中需要唯一 ID 元素提供 ID,例如 `<label for="ID">` 。
|
||||||
- SSR 到客户端注入时需要 ID 避免错误。
|
- SSR 到客户端注入时需要 ID 避免错误。
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/Input.tsx': {
|
'/Input.tsx': {
|
||||||
@ -147,7 +147,7 @@ export default store;
|
|||||||
|
|
||||||
其中, `listeners` 用于存放 `subscribe` 的回调,在我们更新状态后需要通知 React 来更新组件。所以在 `setState` 中遍历执行。之所以使用 `Set()` 是因为 `subscribe` 还需要返回一个函数用于注销 `listener` 。
|
其中, `listeners` 用于存放 `subscribe` 的回调,在我们更新状态后需要通知 React 来更新组件。所以在 `setState` 中遍历执行。之所以使用 `Set()` 是因为 `subscribe` 还需要返回一个函数用于注销 `listener` 。
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/Input.tsx': {
|
'/Input.tsx': {
|
||||||
@ -171,7 +171,7 @@ CSS-in-JS 库通常需要在运行时插入或修改 `<style>` 标签等。当
|
|||||||
|
|
||||||
解决这个问题的最好办法就是所有东西呈现给浏览器绘制前就进行改变。没错 `useInsertionEffect` 与 `useEffect` 有着同样的签名,但它会同步的在所有 DOM 更改之前触发。比 `useLayoutEffect` 还要早触发,这样就可以用于在重绘之前注入样式。
|
解决这个问题的最好办法就是所有东西呈现给浏览器绘制前就进行改变。没错 `useInsertionEffect` 与 `useEffect` 有着同样的签名,但它会同步的在所有 DOM 更改之前触发。比 `useLayoutEffect` 还要早触发,这样就可以用于在重绘之前注入样式。
|
||||||
|
|
||||||
<RUASandpack
|
<RuaSandpack
|
||||||
template="react-ts"
|
template="react-ts"
|
||||||
files={{
|
files={{
|
||||||
'/App.tsx': sandpack['react18-new-hooks'].useInsertionEffect,
|
'/App.tsx': sandpack['react18-new-hooks'].useInsertionEffect,
|
||||||
|
@ -166,7 +166,7 @@ myPosts.push({
|
|||||||
Algolia API is easy to use. First we need specify the index name.
|
Algolia API is easy to use. First we need specify the index name.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const index = client.initIndex('RUA');
|
const index = client.initIndex('rua');
|
||||||
```
|
```
|
||||||
|
|
||||||
And save the objects.
|
And save the objects.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
|
|
||||||
const Footer = dynamic(() => import('components/Footer'));
|
const Footer = dynamic(() => import('components/footer'));
|
||||||
const HeadBar = dynamic(() => import('components/NavBar'));
|
const HeadBar = dynamic(() => import('components/nav-bar'));
|
||||||
const BackToTop = dynamic(() => import('components/common/BackToTop'));
|
const BackToTop = dynamic(() => import('components/common/back-to-top'));
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
@ -1,4 +1,4 @@
|
|||||||
import useRouterLoading from 'lib/hooks/useRouterLoading';
|
import useRouterLoading from 'lib/hooks/use-router-loading';
|
||||||
import { ThemeProvider } from 'next-themes';
|
import { ThemeProvider } from 'next-themes';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
@ -10,7 +10,7 @@ import 'styles/rua.css';
|
|||||||
import { AppPropsWithLayout } from 'types';
|
import { AppPropsWithLayout } from 'types';
|
||||||
|
|
||||||
const VercelLoading = dynamic(
|
const VercelLoading = dynamic(
|
||||||
() => import('components/RUA/loading/VercelLoading'),
|
() => import('components/rua/loading/vercel-loading'),
|
||||||
{
|
{
|
||||||
suspense: true,
|
suspense: true,
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import TWEEN from '@tweenjs/tween.js';
|
import TWEEN from '@tweenjs/tween.js';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
import { gltfLoader, manager } from 'lib/gltfLoader';
|
import { gltfLoader, manager } from 'lib/gltf-loader';
|
||||||
import { getMousePosition } from 'lib/utils';
|
import { getMousePosition } from 'lib/utils';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
@ -10,7 +10,7 @@ import { InitFn, THREE, useThree } from 'rua-three';
|
|||||||
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
||||||
import { NextPageWithLayout } from 'types';
|
import { NextPageWithLayout } from 'types';
|
||||||
|
|
||||||
const Loading = dynamic(() => import('components/RUA/loading/RUALoading'), {
|
const Loading = dynamic(() => import('components/rua/loading/rua-loading'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import PostCardLoading from 'components/RUA/loading/PostCardLoading';
|
import PostCardLoading from 'components/rua/loading/post-card-loading';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
import { getPostListPath, postLists, PostPerPage } from 'lib/posts';
|
import { getPostListPath, postLists, PostPerPage } from 'lib/posts';
|
||||||
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
|
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { Fragment, ReactElement, Suspense } from 'react';
|
import { Fragment, ReactElement, Suspense } from 'react';
|
||||||
import { Post } from 'types';
|
import { Post } from 'types';
|
||||||
|
|
||||||
const PostCard = dynamic(() => import('components/PostCard'), {
|
const PostCard = dynamic(() => import('components/post-card'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
const BlogList = dynamic(() => import('layouts/BlogList'), { suspense: true });
|
const BlogList = dynamic(() => import('layouts/blog-list'), { suspense: true });
|
||||||
const Pagination = dynamic(() => import('components/RUA/RUAPagination'), {
|
const Pagination = dynamic(() => import('components/rua/rua-pagination'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import PostCardLoading from 'components/RUA/loading/PostCardLoading';
|
import PostCardLoading from 'components/rua/loading/post-card-loading';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
import { postLists, PostPerPage } from 'lib/posts';
|
import { postLists, PostPerPage } from 'lib/posts';
|
||||||
import { GetStaticProps, InferGetStaticPropsType } from 'next';
|
import { GetStaticProps, InferGetStaticPropsType } from 'next';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { Fragment, ReactElement, Suspense } from 'react';
|
import { Fragment, ReactElement, Suspense } from 'react';
|
||||||
import { Post } from 'types';
|
import { Post } from 'types';
|
||||||
|
|
||||||
const PostCard = dynamic(() => import('components/PostCard'), {
|
const PostCard = dynamic(() => import('components/post-card'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
const BlogList = dynamic(() => import('layouts/BlogList'), { suspense: true });
|
const BlogList = dynamic(() => import('layouts/blog-list'), { suspense: true });
|
||||||
const Pagination = dynamic(() => import('components/RUA/RUAPagination'), {
|
const Pagination = dynamic(() => import('components/rua/rua-pagination'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import LinkAnchor from 'components/mdx/LinkAnchor';
|
import LinkAnchor from 'components/mdx/link-anchor';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
import { getGists, getSignalGist, SingalGist } from 'lib/fetcher';
|
import { getGists, getSignalGist, SingalGist } from 'lib/fetcher';
|
||||||
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
|
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
@ -11,7 +11,7 @@ import avatar from 'public/images/img/avatar.svg';
|
|||||||
import { ParsedUrlQuery } from 'querystring';
|
import { ParsedUrlQuery } from 'querystring';
|
||||||
import { Fragment, ReactElement, Suspense } from 'react';
|
import { Fragment, ReactElement, Suspense } from 'react';
|
||||||
|
|
||||||
const GistsCode = dynamic(() => import('components/gists/GistsCode'), {
|
const GistsCode = dynamic(() => import('components/gists/gists-code'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
import { GetGists, getGists, GetUser, getUser } from 'lib/fetcher';
|
import { GetGists, getGists, GetUser, getUser } from 'lib/fetcher';
|
||||||
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
|
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { ParsedUrlQuery } from 'querystring';
|
import { ParsedUrlQuery } from 'querystring';
|
||||||
import { ReactElement, Suspense } from 'react';
|
import { ReactElement, Suspense } from 'react';
|
||||||
|
|
||||||
const UserInfo = dynamic(() => import('components/gists/UserInfo'), {
|
const UserInfo = dynamic(() => import('components/gists/user-info'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
const FileContent = dynamic(() => import('components/gists/FileContent'), {
|
const FileContent = dynamic(() => import('components/gists/file-content'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
const Pagination = dynamic(() => import('components/RUA/RUAPagination'), {
|
const Pagination = dynamic(() => import('components/rua/rua-pagination'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
import { GetGists, getGists, GetUser, getUser } from 'lib/fetcher';
|
import { GetGists, getGists, GetUser, getUser } from 'lib/fetcher';
|
||||||
import { GetStaticProps, InferGetStaticPropsType } from 'next';
|
import { GetStaticProps, InferGetStaticPropsType } from 'next';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { ReactElement, Suspense } from 'react';
|
import { ReactElement, Suspense } from 'react';
|
||||||
|
|
||||||
const UserInfo = dynamic(() => import('components/gists/UserInfo'), {
|
const UserInfo = dynamic(() => import('components/gists/user-info'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
const FileContent = dynamic(() => import('components/gists/FileContent'), {
|
const FileContent = dynamic(() => import('components/gists/file-content'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
const Pagination = dynamic(() => import('components/RUA/RUAPagination'), {
|
const Pagination = dynamic(() => import('components/rua/rua-pagination'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
import { gltfLoader, manager } from 'lib/gltfLoader';
|
import { gltfLoader, manager } from 'lib/gltf-loader';
|
||||||
import { getMousePosition } from 'lib/utils';
|
import { getMousePosition } from 'lib/utils';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
@ -11,7 +11,7 @@ import styles from 'styles/index/index.module.css';
|
|||||||
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
||||||
import type { NextPageWithLayout } from 'types';
|
import type { NextPageWithLayout } from 'types';
|
||||||
|
|
||||||
const Loading = dynamic(() => import('components/RUA/loading/RUALoading'), {
|
const Loading = dynamic(() => import('components/rua/loading/rua-loading'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import rehypePrism from '@mapbox/rehype-prism';
|
import rehypePrism from '@mapbox/rehype-prism';
|
||||||
import components from 'components/mdx/components';
|
import components from 'components/mdx/components';
|
||||||
import PostCommnetLine from 'components/post/PostCommnetLine';
|
import PostCommnetLine from 'components/post/post-commnet-line';
|
||||||
import PostToc from 'components/post/PostToc';
|
import PostToc from 'components/post/post-toc';
|
||||||
import data from 'content/mdxData';
|
import data from 'content/mdx-data';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
import useInView from 'lib/hooks/useInView';
|
import useInView from 'lib/hooks/use-in-view';
|
||||||
import { allPostsPath, readSinglePost } from 'lib/posts';
|
import { allPostsPath, readSinglePost } from 'lib/posts';
|
||||||
import { generateToc, SingleToc } from 'lib/utils';
|
import { generateToc, SingleToc } from 'lib/utils';
|
||||||
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
|
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';
|
||||||
@ -15,7 +15,7 @@ import { ReactElement, Suspense } from 'react';
|
|||||||
import rehypeSlug from 'rehype-slug';
|
import rehypeSlug from 'rehype-slug';
|
||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
|
|
||||||
const PostComment = dynamic(() => import('components/post/PostComment'), {
|
const PostComment = dynamic(() => import('components/post/post-comment'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ import {
|
|||||||
} from 'react-icons/si';
|
} from 'react-icons/si';
|
||||||
import { VscGithubInverted } from 'react-icons/vsc';
|
import { VscGithubInverted } from 'react-icons/vsc';
|
||||||
import { HiPhoto } from 'react-icons/hi2';
|
import { HiPhoto } from 'react-icons/hi2';
|
||||||
import MainLayout from 'layouts/MainLayout';
|
import MainLayout from 'layouts/main-layout';
|
||||||
|
|
||||||
const ProjectCard = dynamic(() => import('components/pages/ProjectCard'), {
|
const ProjectCard = dynamic(() => import('components/pages/project-card'), {
|
||||||
suspense: true,
|
suspense: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ async function pushAlgolia(gists) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// initialize the index with your index name
|
// initialize the index with your index name
|
||||||
const index = client.initIndex('RUA');
|
const index = client.initIndex('rua');
|
||||||
|
|
||||||
// save the objects!
|
// save the objects!
|
||||||
const algoliaResponse = await index.replaceAllObjects(records);
|
const algoliaResponse = await index.replaceAllObjects(records);
|
||||||
@ -61,4 +61,4 @@ function main() {
|
|||||||
isTest ? test(gists) : pushAlgolia(gists);
|
isTest ? test(gists) : pushAlgolia(gists);
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
Reference in New Issue
Block a user