@umami/shiso 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/.eslintrc.json +0 -11
- package/.prettierrc.json +0 -7
- package/dts.mjs +0 -8
- package/esbuild.mjs +0 -36
- package/next.config.ts +0 -15
- package/public/leaf.png +0 -0
- package/public/leaf.svg +0 -1
- package/src/app/Footer.tsx +0 -14
- package/src/app/Header.tsx +0 -14
- package/src/app/blog/[[...id]]/page.tsx +0 -8
- package/src/app/docs/[[...id]]/page.tsx +0 -8
- package/src/app/layout.tsx +0 -41
- package/src/app/page.tsx +0 -25
- package/src/assets/leaf.svg +0 -1
- package/src/components/Footer.module.css +0 -0
- package/src/components/Footer.tsx +0 -1
- package/src/components/Header.module.css +0 -0
- package/src/components/Header.tsx +0 -0
- package/src/components/Markdown.tsx +0 -21
- package/src/components/Shiso.tsx +0 -19
- package/src/components/blog/Blog.module.css +0 -0
- package/src/components/blog/Blog.tsx +0 -21
- package/src/components/docs/Callout.module.css +0 -6
- package/src/components/docs/Callout.tsx +0 -18
- package/src/components/docs/CodeBlock.module.css +0 -37
- package/src/components/docs/CodeBlock.tsx +0 -30
- package/src/components/docs/ContentArea.module.css +0 -63
- package/src/components/docs/ContentArea.tsx +0 -27
- package/src/components/docs/Docs.tsx +0 -50
- package/src/components/docs/Note.tsx +0 -5
- package/src/components/docs/PageLinks.module.css +0 -49
- package/src/components/docs/PageLinks.tsx +0 -49
- package/src/components/docs/SideNav.module.css +0 -32
- package/src/components/docs/SideNav.tsx +0 -46
- package/src/components/docs/TopNav.tsx +0 -25
- package/src/components/icons/Leaf.tsx +0 -15
- package/src/components/icons/index.ts +0 -1
- package/src/components/index.ts +0 -8
- package/src/content/blog/index.mdx +0 -5
- package/src/content/docs/components/index.mdx +0 -1
- package/src/content/docs/components.mdx +0 -5
- package/src/content/docs/configuration.mdx +0 -81
- package/src/content/docs/index.mdx +0 -11
- package/src/content/docs/installation.mdx +0 -38
- package/src/content/docs/writing-content.mdx +0 -95
- package/src/declarations.d.ts +0 -3
- package/src/index.ts +0 -5
- package/src/lib/content.ts +0 -61
- package/src/lib/next.tsx +0 -46
- package/src/lib/types.ts +0 -10
- package/src/shiso.config.json +0 -59
- package/tsconfig.build.json +0 -24
- package/tsconfig.json +0 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umami/shiso",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A content layer for Next.js",
|
|
5
5
|
"homepage": "https://umami.is/shiso",
|
|
6
6
|
"repository": {
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"main": "dist/index.js",
|
|
14
14
|
"module": "dist/index.mjs",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
16
19
|
"scripts": {
|
|
17
20
|
"dev": "next dev --port 3100",
|
|
18
21
|
"build": "next build",
|
package/.eslintrc.json
DELETED
package/.prettierrc.json
DELETED
package/dts.mjs
DELETED
package/esbuild.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import esbuild from 'esbuild';
|
|
2
|
-
import cssModules from '@umami/esbuild-plugin-css-modules';
|
|
3
|
-
import pkg from './package.json' with { type: 'json' };
|
|
4
|
-
|
|
5
|
-
const { dependencies } = pkg;
|
|
6
|
-
|
|
7
|
-
const config = {
|
|
8
|
-
entryPoints: ['src/index.ts'],
|
|
9
|
-
bundle: true,
|
|
10
|
-
external: Object.keys(dependencies),
|
|
11
|
-
jsx: 'automatic',
|
|
12
|
-
platform: 'node',
|
|
13
|
-
plugins: [cssModules()],
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
esbuild
|
|
17
|
-
.build({
|
|
18
|
-
...config,
|
|
19
|
-
outfile: 'dist/index.js',
|
|
20
|
-
format: 'cjs',
|
|
21
|
-
})
|
|
22
|
-
.catch(e => {
|
|
23
|
-
console.error(e);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
esbuild
|
|
28
|
-
.build({
|
|
29
|
-
...config,
|
|
30
|
-
outfile: 'dist/index.mjs',
|
|
31
|
-
format: 'esm',
|
|
32
|
-
})
|
|
33
|
-
.catch(e => {
|
|
34
|
-
console.error(e);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
});
|
package/next.config.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { NextConfig } from 'next';
|
|
2
|
-
|
|
3
|
-
const nextConfig: NextConfig = {
|
|
4
|
-
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
|
|
5
|
-
reactStrictMode: false,
|
|
6
|
-
output: 'standalone',
|
|
7
|
-
eslint: {
|
|
8
|
-
ignoreDuringBuilds: true,
|
|
9
|
-
},
|
|
10
|
-
typescript: {
|
|
11
|
-
ignoreBuildErrors: true,
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default nextConfig;
|
package/public/leaf.png
DELETED
|
Binary file
|
package/public/leaf.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg id="Glyph_Icon" height="512" viewBox="0 0 64 64" width="512" xmlns="http://www.w3.org/2000/svg" data-name="Glyph Icon"><path d="m55.221 10.79c-.555-.242-1.182-.085-1.564.39-4.738 5.882-18.607 6.77-22.746 6.903-1.002.032-2.035.155-3.067.366-20.567 4.187-20.255 19.314-19.671 23.85.097.75.601 1.362 1.315 1.599.708.236 1.469.045 1.988-.492 2.403-2.49 7.671-6.969 15.952-8.985 3.422-.833 6.668-2.36 9.557-4.111-3.375 2.564-7.731 5.332-13.243 7.92-5.526 2.596-9.586 7.096-11.075 8.909-.339.413-.493.953-.423 1.483.072.536.368 1.023.812 1.338 1.414 1.004 3.099 1.813 5.006 2.408 2.053.638 4.168.954 6.286.954 4.28 0 8.564-1.287 12.329-3.782 14.464-9.588 18.439-31.031 19.312-37.373.082-.588-.227-1.141-.768-1.377z"/></svg>
|
package/src/app/Footer.tsx
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Box, Text } from '@umami/react-zen';
|
|
2
|
-
|
|
3
|
-
export function Footer() {
|
|
4
|
-
return (
|
|
5
|
-
<Box as="footer" paddingY="8">
|
|
6
|
-
<Text align="center" as="div">
|
|
7
|
-
Built by{' '}
|
|
8
|
-
<a href="https://umami.is">
|
|
9
|
-
<strong>umami</strong>
|
|
10
|
-
</a>
|
|
11
|
-
</Text>
|
|
12
|
-
</Box>
|
|
13
|
-
);
|
|
14
|
-
}
|
package/src/app/Header.tsx
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Row, Text } from '@umami/react-zen';
|
|
2
|
-
import Link from 'next/link';
|
|
3
|
-
|
|
4
|
-
export function Header() {
|
|
5
|
-
return (
|
|
6
|
-
<Row paddingY="5" gap="5" alignItems="center">
|
|
7
|
-
<Text size="5" weight="bold" spacing="1" asChild>
|
|
8
|
-
<Link href="/">shiso</Link>
|
|
9
|
-
</Text>
|
|
10
|
-
<Link href="/docs">docs</Link>
|
|
11
|
-
<Link href="/blog">blog</Link>
|
|
12
|
-
</Row>
|
|
13
|
-
);
|
|
14
|
-
}
|
package/src/app/layout.tsx
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ReactNode, Suspense } from 'react';
|
|
2
|
-
import type { Metadata } from 'next';
|
|
3
|
-
import { Inter } from 'next/font/google';
|
|
4
|
-
import { Container, Column } from '@umami/react-zen';
|
|
5
|
-
import { Header } from './Header';
|
|
6
|
-
import { Footer } from './Footer';
|
|
7
|
-
import '@umami/react-zen/dist/styles.css';
|
|
8
|
-
import 'highlight.js/styles/github-dark.css';
|
|
9
|
-
|
|
10
|
-
const inter = Inter({ subsets: ['latin'] });
|
|
11
|
-
|
|
12
|
-
export const metadata: Metadata = {
|
|
13
|
-
title: 'Shiso',
|
|
14
|
-
description: 'MDX powered content',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default function RootLayout({
|
|
18
|
-
children,
|
|
19
|
-
}: Readonly<{
|
|
20
|
-
children: ReactNode;
|
|
21
|
-
}>) {
|
|
22
|
-
return (
|
|
23
|
-
<html lang="en">
|
|
24
|
-
<head>
|
|
25
|
-
<title>shiso</title>
|
|
26
|
-
<link rel="icon" type="image/png" href="/leaf.png" />
|
|
27
|
-
</head>
|
|
28
|
-
<body className={inter.className}>
|
|
29
|
-
<Suspense>
|
|
30
|
-
<Container>
|
|
31
|
-
<Column height="100vh" className="ohhyeaaaaa">
|
|
32
|
-
<Header />
|
|
33
|
-
{children}
|
|
34
|
-
<Footer />
|
|
35
|
-
</Column>
|
|
36
|
-
</Container>
|
|
37
|
-
</Suspense>
|
|
38
|
-
</body>
|
|
39
|
-
</html>
|
|
40
|
-
);
|
|
41
|
-
}
|
package/src/app/page.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Heading, Text, Row, Column, Icon, Button } from '@umami/react-zen';
|
|
2
|
-
import Link from 'next/link';
|
|
3
|
-
import Leaf from '@/components/icons/Leaf';
|
|
4
|
-
|
|
5
|
-
export default function Home() {
|
|
6
|
-
return (
|
|
7
|
-
<Column gap="3" style={{ margin: '0 auto' }} flexGrow={1}>
|
|
8
|
-
<Heading size="5">shiso</Heading>
|
|
9
|
-
<Icon size="lg">
|
|
10
|
-
<Leaf />
|
|
11
|
-
</Icon>
|
|
12
|
-
<Text as="p" type="muted">
|
|
13
|
-
Publish content using MDX.
|
|
14
|
-
</Text>
|
|
15
|
-
<Row gap="3">
|
|
16
|
-
<Button variant="primary" asChild>
|
|
17
|
-
<Link href="/docs">Get started</Link>
|
|
18
|
-
</Button>
|
|
19
|
-
<Button asChild>
|
|
20
|
-
<Link href="https://github.com/umami-software/shiso">View code</Link>
|
|
21
|
-
</Button>
|
|
22
|
-
</Row>
|
|
23
|
-
</Column>
|
|
24
|
-
);
|
|
25
|
-
}
|
package/src/assets/leaf.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg id="Glyph_Icon" height="512" viewBox="0 0 64 64" width="512" xmlns="http://www.w3.org/2000/svg" data-name="Glyph Icon"><path d="m55.221 10.79c-.555-.242-1.182-.085-1.564.39-4.738 5.882-18.607 6.77-22.746 6.903-1.002.032-2.035.155-3.067.366-20.567 4.187-20.255 19.314-19.671 23.85.097.75.601 1.362 1.315 1.599.708.236 1.469.045 1.988-.492 2.403-2.49 7.671-6.969 15.952-8.985 3.422-.833 6.668-2.36 9.557-4.111-3.375 2.564-7.731 5.332-13.243 7.92-5.526 2.596-9.586 7.096-11.075 8.909-.339.413-.493.953-.423 1.483.072.536.368 1.023.812 1.338 1.414 1.004 3.099 1.813 5.006 2.408 2.053.638 4.168.954 6.286.954 4.28 0 8.564-1.287 12.329-3.782 14.464-9.588 18.439-31.031 19.312-37.373.082-.588-.227-1.141-.768-1.377z"/></svg>
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function Footer() {}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { MDXRemote } from 'next-mdx-remote/rsc';
|
|
2
|
-
import remarkGfm from 'remark-gfm';
|
|
3
|
-
import rehypeHighlight from 'rehype-highlight';
|
|
4
|
-
import Link, { LinkProps } from 'next/link';
|
|
5
|
-
import { CodeBlock } from '@/components/docs/CodeBlock';
|
|
6
|
-
|
|
7
|
-
const options = {
|
|
8
|
-
mdxOptions: {
|
|
9
|
-
remarkPlugins: [remarkGfm],
|
|
10
|
-
rehypePlugins: [rehypeHighlight],
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const components = {
|
|
15
|
-
a: (props: any) => <Link {...(props as LinkProps)} />,
|
|
16
|
-
pre: CodeBlock,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default function Markdown({ children }) {
|
|
20
|
-
return <MDXRemote source={children as any} components={components} options={options} />;
|
|
21
|
-
}
|
package/src/components/Shiso.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { ReactNode, createContext } from 'react';
|
|
3
|
-
|
|
4
|
-
export interface ShisoConfig {
|
|
5
|
-
contentDir: string;
|
|
6
|
-
docs?: { [key: string]: any };
|
|
7
|
-
blog?: { [key: string]: any };
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ShisoProps {
|
|
11
|
-
config: ShisoConfig;
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const ShisoContext = createContext({ config: {} as ShisoConfig });
|
|
16
|
-
|
|
17
|
-
export function Shiso({ config, children }: ShisoProps) {
|
|
18
|
-
return <ShisoContext.Provider value={{ config }}>{children}</ShisoContext.Provider>;
|
|
19
|
-
}
|
|
File without changes
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import styles from './Blog.module.css';
|
|
2
|
-
import Markdown from '../Markdown';
|
|
3
|
-
|
|
4
|
-
export interface BlogProps {
|
|
5
|
-
content: any;
|
|
6
|
-
config: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function Blog({ content }: BlogProps) {
|
|
10
|
-
return (
|
|
11
|
-
<div className={styles.blog}>
|
|
12
|
-
<div className={styles.main}>
|
|
13
|
-
<div className={styles.content}>
|
|
14
|
-
<h1>{content?.meta?.title}</h1>
|
|
15
|
-
<p className={styles.description}>{content?.meta?.description}</p>
|
|
16
|
-
<Markdown>{content?.body}</Markdown>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import styles from './Callout.module.css';
|
|
4
|
-
|
|
5
|
-
export interface CalloutProps {
|
|
6
|
-
variant: 'note' | 'warning' | 'info' | 'tip';
|
|
7
|
-
icon?: ReactNode;
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default function Callout({ variant = 'note', icon, children }: CalloutProps) {
|
|
12
|
-
return (
|
|
13
|
-
<div className={classNames(styles[variant])}>
|
|
14
|
-
{icon}
|
|
15
|
-
{children}
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
position: relative;
|
|
3
|
-
background: var(--base-color-900);
|
|
4
|
-
padding: var(--spacing-5);
|
|
5
|
-
border-radius: 6px;
|
|
6
|
-
white-space: pre-wrap;
|
|
7
|
-
word-wrap: break-word;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
pre.container code {
|
|
11
|
-
font-family: var(--font-family-code);
|
|
12
|
-
color: var(--base-color-300);
|
|
13
|
-
padding: 0;
|
|
14
|
-
border: 0;
|
|
15
|
-
background: transparent;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.button {
|
|
19
|
-
border: 0;
|
|
20
|
-
position: absolute;
|
|
21
|
-
right: var(--spacing-5);
|
|
22
|
-
top: var(--spacing-5);
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
background: transparent;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.copy {
|
|
28
|
-
color: var(--base-color-300);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.copy:hover {
|
|
32
|
-
color: var(--base-color-50);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.check {
|
|
36
|
-
color: var(--success-color);
|
|
37
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useState, useRef } from 'react';
|
|
3
|
-
import { Icon, Icons } from '@umami/react-zen';
|
|
4
|
-
import styles from './CodeBlock.module.css';
|
|
5
|
-
|
|
6
|
-
export function CodeBlock(props: any) {
|
|
7
|
-
const textInput = useRef<any>(null);
|
|
8
|
-
const [copied, setCopied] = useState(false);
|
|
9
|
-
|
|
10
|
-
const handleCopy = () => {
|
|
11
|
-
setCopied(true);
|
|
12
|
-
|
|
13
|
-
navigator?.clipboard?.writeText(textInput?.current?.textContent);
|
|
14
|
-
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
setCopied(false);
|
|
17
|
-
}, 1000);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<pre ref={textInput} className={styles.container}>
|
|
22
|
-
{props.children}
|
|
23
|
-
<button aria-label="Copy code" className={styles.button} onClick={handleCopy}>
|
|
24
|
-
<Icon size="sm" className={copied ? styles.check : styles.copy}>
|
|
25
|
-
{copied ? <Icons.Check /> : <Icons.Copy />}
|
|
26
|
-
</Icon>
|
|
27
|
-
</button>
|
|
28
|
-
</pre>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
.content {
|
|
2
|
-
font-size: 16px;
|
|
3
|
-
margin-bottom: 60px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.content > p {
|
|
7
|
-
color: var(--font-muted-color);
|
|
8
|
-
line-height: 1.8;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.content a {
|
|
12
|
-
color: var(--font-color);
|
|
13
|
-
font-weight: 600;
|
|
14
|
-
text-decoration: underline var(--font-faded-color);
|
|
15
|
-
text-underline-offset: 4px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.content a:hover {
|
|
19
|
-
text-decoration: underline var(--font-color);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.content h1 {
|
|
23
|
-
font-size: var(--font-size-8);
|
|
24
|
-
letter-spacing: var(--letter-spacing-1);
|
|
25
|
-
margin: 0 0 var(--spacing-4) 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.content h2 {
|
|
29
|
-
font-size: var(--font-size-6);
|
|
30
|
-
letter-spacing: var(--letter-spacing-1);
|
|
31
|
-
margin: var(--spacing-8) 0 var(--spacing-4) 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.content h3 {
|
|
35
|
-
font-size: var(--font-size-5);
|
|
36
|
-
letter-spacing: var(--letter-spacing-1);
|
|
37
|
-
margin: var(--spacing-7) 0 var(--spacing-4) 0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.content ul {
|
|
41
|
-
list-style: disc;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.content ol {
|
|
45
|
-
list-style: decimal;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.content pre {
|
|
49
|
-
margin: var(--spacing-5) 0;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.content code {
|
|
53
|
-
font-size: 14px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.content code:not([class]) {
|
|
57
|
-
font-family: var(--font-family-code);
|
|
58
|
-
color: var(--font-color);
|
|
59
|
-
padding: var(--spacing-1);
|
|
60
|
-
border-radius: var(--border-radius);
|
|
61
|
-
background: var(--base-color-50);
|
|
62
|
-
font-weight: var(--font-weight-bold);
|
|
63
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Heading, Box, Text } from '@umami/react-zen';
|
|
2
|
-
import Markdown from '@/components/Markdown';
|
|
3
|
-
import styles from './ContentArea.module.css';
|
|
4
|
-
|
|
5
|
-
export interface ContentAreaProps {
|
|
6
|
-
title: string;
|
|
7
|
-
body: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
group?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function ContentArea({ title, description, group, body }: ContentAreaProps) {
|
|
13
|
-
return (
|
|
14
|
-
<Box flexGrow={1}>
|
|
15
|
-
<Text color="primary" weight="bold">
|
|
16
|
-
{group}
|
|
17
|
-
</Text>
|
|
18
|
-
<Heading size="8" as="h1">
|
|
19
|
-
{title}
|
|
20
|
-
</Heading>
|
|
21
|
-
<Text type="muted">{description}</Text>
|
|
22
|
-
<Box className={styles.content}>
|
|
23
|
-
<Markdown>{body}</Markdown>
|
|
24
|
-
</Box>
|
|
25
|
-
</Box>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Grid, Box, Heading } from '@umami/react-zen';
|
|
2
|
-
import PageLinks from './PageLinks';
|
|
3
|
-
import SideNav from './SideNav';
|
|
4
|
-
import TopNav from './TopNav';
|
|
5
|
-
import { ContentArea } from './ContentArea';
|
|
6
|
-
import { ShisoConfig } from '../Shiso';
|
|
7
|
-
|
|
8
|
-
export interface contentsProps {
|
|
9
|
-
config: ShisoConfig;
|
|
10
|
-
content: any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function Docs({ content, config }: contentsProps) {
|
|
14
|
-
if (!content) {
|
|
15
|
-
return <Heading size="6">Page not found</Heading>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const { tabs, navigation } = config?.docs || {};
|
|
19
|
-
|
|
20
|
-
content.group = Object.keys(navigation).reduce((name, key) => {
|
|
21
|
-
if (!name) {
|
|
22
|
-
return navigation[key]?.find((section: { pages: any[] }) => {
|
|
23
|
-
return section.pages.find(
|
|
24
|
-
page =>
|
|
25
|
-
page.url === `/docs/${content.id}` || (page.url === `/docs` && content.id === 'index'),
|
|
26
|
-
);
|
|
27
|
-
})?.group;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return name;
|
|
31
|
-
}, null);
|
|
32
|
-
|
|
33
|
-
console.log({ config, tabs, content });
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<Box flexGrow="1">
|
|
37
|
-
{tabs && <TopNav tabs={tabs} />}
|
|
38
|
-
<Grid gap="6" columns="240px 1fr 240px">
|
|
39
|
-
<SideNav tabs={tabs} navigation={navigation} />
|
|
40
|
-
<ContentArea
|
|
41
|
-
title={content?.meta?.title}
|
|
42
|
-
body={content?.body}
|
|
43
|
-
group={content?.group}
|
|
44
|
-
description={content?.meta?.description}
|
|
45
|
-
/>
|
|
46
|
-
<PageLinks items={content?.anchors} offset={150} />
|
|
47
|
-
</Grid>
|
|
48
|
-
</Box>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
.title {
|
|
2
|
-
position: sticky;
|
|
3
|
-
top: 0;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.links {
|
|
7
|
-
position: sticky;
|
|
8
|
-
top: 30px;
|
|
9
|
-
height: max-content;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.links a {
|
|
13
|
-
display: block;
|
|
14
|
-
color: var(--font-muted-color);
|
|
15
|
-
text-wrap: nowrap;
|
|
16
|
-
text-decoration: none;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.links a:hover {
|
|
20
|
-
color: var(--primary-color);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.indent-1 {
|
|
24
|
-
margin-left: 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.indent-2 {
|
|
28
|
-
margin-left: 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.indent-3 {
|
|
32
|
-
margin-left: 10px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.indent-4 {
|
|
36
|
-
margin-left: 20px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.indent-5 {
|
|
40
|
-
margin-left: 30px;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.indent-6 {
|
|
44
|
-
margin-left: 40px;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
a.selected {
|
|
48
|
-
color: var(--primary-color);
|
|
49
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { Column, Text } from '@umami/react-zen';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import styles from './PageLinks.module.css';
|
|
6
|
-
|
|
7
|
-
export default function PageLinks({ items, offset = 0 }) {
|
|
8
|
-
const [hash, setHash] = useState(items?.[0]?.id);
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const callback = () => {
|
|
12
|
-
const x = [...items].reverse().find(({ id }) => {
|
|
13
|
-
const rect = document.getElementById(id)?.getBoundingClientRect();
|
|
14
|
-
return rect && rect.top <= offset;
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
if (x) setHash(x.id);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
window.addEventListener('scroll', callback, false);
|
|
21
|
-
|
|
22
|
-
return () => {
|
|
23
|
-
window.removeEventListener('scroll', callback, false);
|
|
24
|
-
};
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
if (!items?.length) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Column gap="3" minWidth="240px" className={styles.links}>
|
|
33
|
-
<Text size="2" weight="bold">
|
|
34
|
-
On this page
|
|
35
|
-
</Text>
|
|
36
|
-
{items.map(({ name, id, size }) => {
|
|
37
|
-
return (
|
|
38
|
-
<a
|
|
39
|
-
key={id}
|
|
40
|
-
href={`#${id}`}
|
|
41
|
-
className={classNames(styles[`indent-${size}`], { [styles.selected]: hash === id })}
|
|
42
|
-
>
|
|
43
|
-
{name}
|
|
44
|
-
</a>
|
|
45
|
-
);
|
|
46
|
-
})}
|
|
47
|
-
</Column>
|
|
48
|
-
);
|
|
49
|
-
}
|