@umami/shiso 0.1.0 → 0.3.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/dist/index.js +1 -5
- package/dist/index.mjs +1 -11
- 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
|
@@ -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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
.nav {
|
|
2
|
-
position: sticky;
|
|
3
|
-
top: 30px;
|
|
4
|
-
height: max-content;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.item {
|
|
8
|
-
color: var(--font-muted-color);
|
|
9
|
-
padding: 0;
|
|
10
|
-
border-radius: 0;
|
|
11
|
-
border-left: var(--border-size-1) solid var(--border-color);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.item a {
|
|
15
|
-
color: currentColor;
|
|
16
|
-
width: 100%;
|
|
17
|
-
padding: var(--padding-y) var(--padding-x);
|
|
18
|
-
text-decoration: none;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.item a:hover {
|
|
22
|
-
color: var(--primary-color);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.item.selected {
|
|
26
|
-
color: var(--font-color);
|
|
27
|
-
border-color: var(--primary-color);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.items header {
|
|
31
|
-
padding: var(--padding-y) 0;
|
|
32
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Box, List, ListItem, ListSection } from '@umami/react-zen';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import { usePathname } from 'next/navigation';
|
|
6
|
-
import Link from 'next/link';
|
|
7
|
-
import styles from './SideNav.module.css';
|
|
8
|
-
|
|
9
|
-
export interface SideNavProps {
|
|
10
|
-
tabs: any;
|
|
11
|
-
navigation: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default function SideNav({ tabs, navigation }: SideNavProps) {
|
|
15
|
-
const pathname = usePathname();
|
|
16
|
-
|
|
17
|
-
const tab = tabs.find(({ url, id }) => (id !== 'docs' ? pathname.startsWith(url) : false));
|
|
18
|
-
const menu = navigation[tab?.id || 'docs'];
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Box className={styles.nav}>
|
|
22
|
-
<List items={navigation}>
|
|
23
|
-
{menu.map(({ group, pages }) => {
|
|
24
|
-
return (
|
|
25
|
-
<ListSection title={group} key={group} className={styles.items}>
|
|
26
|
-
{pages.map(({ label: text, url }, index: number) => {
|
|
27
|
-
return (
|
|
28
|
-
<ListItem
|
|
29
|
-
key={index}
|
|
30
|
-
className={classNames(styles.item, {
|
|
31
|
-
[styles.selected]: url === pathname,
|
|
32
|
-
})}
|
|
33
|
-
>
|
|
34
|
-
<Link href={url} prefetch={false}>
|
|
35
|
-
{text}
|
|
36
|
-
</Link>
|
|
37
|
-
</ListItem>
|
|
38
|
-
);
|
|
39
|
-
})}
|
|
40
|
-
</ListSection>
|
|
41
|
-
);
|
|
42
|
-
})}
|
|
43
|
-
</List>
|
|
44
|
-
</Box>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import Link from 'next/link';
|
|
3
|
-
import { usePathname } from 'next/navigation';
|
|
4
|
-
import { Tabs, TabList, Tab } from '@umami/react-zen';
|
|
5
|
-
|
|
6
|
-
export default function TopNav({ tabs }) {
|
|
7
|
-
const pathname = usePathname();
|
|
8
|
-
|
|
9
|
-
const tab = tabs.find(({ id, url }) => (id !== 'docs' ? pathname.startsWith(url) : false));
|
|
10
|
-
const selected = tab?.id || 'docs';
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<Tabs selectedKey={selected}>
|
|
14
|
-
<TabList items={tabs}>
|
|
15
|
-
{({ id, label, url }) => {
|
|
16
|
-
return (
|
|
17
|
-
<Tab id={id}>
|
|
18
|
-
<Link href={url}>{label}</Link>
|
|
19
|
-
</Tab>
|
|
20
|
-
);
|
|
21
|
-
}}
|
|
22
|
-
</TabList>
|
|
23
|
-
</Tabs>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { SVGProps } from 'react';
|
|
3
|
-
const SvgLeaf = (props: SVGProps<SVGSVGElement>) => (
|
|
4
|
-
<svg
|
|
5
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
-
width={512}
|
|
7
|
-
height={512}
|
|
8
|
-
data-name="Glyph Icon"
|
|
9
|
-
viewBox="0 0 64 64"
|
|
10
|
-
{...props}
|
|
11
|
-
>
|
|
12
|
-
<path d="M55.221 10.79a1.31 1.31 0 0 0-1.564.39c-4.738 5.882-18.607 6.77-22.746 6.903a18.3 18.3 0 0 0-3.067.366C7.277 22.636 7.589 37.763 8.173 42.299c.097.75.601 1.362 1.315 1.599a1.91 1.91 0 0 0 1.988-.492c2.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.909a1.94 1.94 0 0 0-.423 1.483c.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.373a1.29 1.29 0 0 0-.768-1.377" />
|
|
13
|
-
</svg>
|
|
14
|
-
);
|
|
15
|
-
export default SvgLeaf;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Leaf } from './Leaf';
|
package/src/components/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Components
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Configuration
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## Config file
|
|
6
|
-
|
|
7
|
-
The `shiso.config.json` file contains the configuration options for your project.
|
|
8
|
-
|
|
9
|
-
The file has the following schema:
|
|
10
|
-
|
|
11
|
-
```json
|
|
12
|
-
{
|
|
13
|
-
"docs": {},
|
|
14
|
-
"blog": {}
|
|
15
|
-
}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
At the root level, the properties represent the different content sections of your project.
|
|
19
|
-
Shiso currently supports `docs` and `blog` content.
|
|
20
|
-
|
|
21
|
-
## Docs options
|
|
22
|
-
|
|
23
|
-
```json
|
|
24
|
-
{
|
|
25
|
-
"docs": {
|
|
26
|
-
"tabs": [
|
|
27
|
-
{
|
|
28
|
-
"id": "docs",
|
|
29
|
-
"label": "Documentation",
|
|
30
|
-
"url": "/docs"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"id": "components",
|
|
34
|
-
"label": "Components",
|
|
35
|
-
"url": "/docs/components"
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
"navigation": {
|
|
39
|
-
"docs": [
|
|
40
|
-
{
|
|
41
|
-
"group": "Getting started",
|
|
42
|
-
"pages": [
|
|
43
|
-
{
|
|
44
|
-
"label": "Overview",
|
|
45
|
-
"url": "/docs"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"label": "Installation",
|
|
49
|
-
"url": "/docs/installation"
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"group": "Basics",
|
|
55
|
-
"pages": [
|
|
56
|
-
{
|
|
57
|
-
"label": "Writing content",
|
|
58
|
-
"url": "/docs/writing-content"
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
"components": [
|
|
64
|
-
{
|
|
65
|
-
"group": "Components",
|
|
66
|
-
"pages": [
|
|
67
|
-
{
|
|
68
|
-
"label": "Overview",
|
|
69
|
-
"url": "/docs/components"
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Blog options
|
|
80
|
-
|
|
81
|
-
...
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Overview
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## What is Shiso?
|
|
6
|
-
|
|
7
|
-
Shiso lets you quickly build websites by focusing on writing content. Shiso takes care of the
|
|
8
|
-
design, layout and functionality while you provide the content through Markdown files. You can also
|
|
9
|
-
embed React components into your content with MDX.
|
|
10
|
-
|
|
11
|
-
Out of the box, Shiso provides templates for docs and blogs and works with [Next.js](/docs/).
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Installation
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
These instructions show how to set up Shiso in a Next.js project.
|
|
6
|
-
|
|
7
|
-
## 1. Install the package
|
|
8
|
-
|
|
9
|
-
```shell
|
|
10
|
-
npm install @umami/shiso
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## 2. Create page
|
|
14
|
-
|
|
15
|
-
In your `app` folder, create a folder for the content section you wish to add.
|
|
16
|
-
|
|
17
|
-
```text
|
|
18
|
-
src
|
|
19
|
-
├── app
|
|
20
|
-
│ └── docs
|
|
21
|
-
│ └── [[...id]]
|
|
22
|
-
│ └── page.jsx
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
In this case we are creating a section for `docs`.
|
|
26
|
-
|
|
27
|
-
In the `page.jsx` file, add the following code:
|
|
28
|
-
|
|
29
|
-
```javascript
|
|
30
|
-
import shiso from '@umami/shiso/next';
|
|
31
|
-
import config from '@/shiso.config.json';
|
|
32
|
-
|
|
33
|
-
const { getMetadata, renderPage } = shiso(config);
|
|
34
|
-
|
|
35
|
-
export const generateMetadata = getMetadata('SHISO');
|
|
36
|
-
|
|
37
|
-
export default renderPage('docs');
|
|
38
|
-
```
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Tracker functions
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
The Umami tracker exposes a function that you can call on your website if you want
|
|
6
|
-
more control over your tracking. By default everything is automatically collected, but you can
|
|
7
|
-
disable this using `data-auto-track="false"` and sending the data yourself.
|
|
8
|
-
See [Tracker configuration](/docs/tracker-configuration).
|
|
9
|
-
|
|
10
|
-
## Functions
|
|
11
|
-
|
|
12
|
-
```js
|
|
13
|
-
umami.track(payload: object);
|
|
14
|
-
|
|
15
|
-
umami.track(event_name: string, event_data: object);
|
|
16
|
-
|
|
17
|
-
umami.identify(session_data: object);
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Pageviews
|
|
21
|
-
|
|
22
|
-
Tracks a page view.
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
umami.track();
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
By default the tracker automatically collects the following properties:
|
|
29
|
-
|
|
30
|
-
- `hostname` - Hostname of server
|
|
31
|
-
- `language` - Browser language
|
|
32
|
-
- `referrer` - Page referrer
|
|
33
|
-
- `screen` - Screen dimensions (eg. 1920x1080)
|
|
34
|
-
- `title` - Page title
|
|
35
|
-
- `url` - Page url
|
|
36
|
-
- `website` - Website ID (required)
|
|
37
|
-
|
|
38
|
-
If you wish to send your own custom payload, pass in an object to the function:
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
umami.track({ website: 'e676c9b4-11e4-4ef1-a4d7-87001773e9f2', url: '/home', title: 'Home page' });
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
The above will only send the properties `website`, `url` and `title`. If you want to include existing properties, pass in a function:
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
umami.track(props => ({ ...props, url: '/home', title: 'Home page' }));
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Events
|
|
51
|
-
|
|
52
|
-
Tracks an event with a given name.
|
|
53
|
-
|
|
54
|
-
```js
|
|
55
|
-
umami.track('signup-button');
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Event Data
|
|
59
|
-
|
|
60
|
-
Tracks an event with dynamic data.
|
|
61
|
-
|
|
62
|
-
```js
|
|
63
|
-
umami.track('signup-button', { name: 'newsletter', id: 123 });
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
When tracking events, the default properties are included in the payload.
|
|
67
|
-
This is equivalent to running:
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
umami.track(props => ({
|
|
71
|
-
...props,
|
|
72
|
-
name: 'signup-button',
|
|
73
|
-
data: {
|
|
74
|
-
name: 'newsletter',
|
|
75
|
-
id: 123,
|
|
76
|
-
},
|
|
77
|
-
}));
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Event Data Limits
|
|
81
|
-
|
|
82
|
-
Event Data can work with any JSON data. There are a few rules in place to maintain performance.
|
|
83
|
-
|
|
84
|
-
- Numbers have a max precision of 4.
|
|
85
|
-
- Strings have a max length of 500.
|
|
86
|
-
- Arrays are converted to a String, with the same max length of 500.
|
|
87
|
-
- Objects have a max of 50 properties. Arrays are considered 1 property.
|
|
88
|
-
|
|
89
|
-
## Session Data
|
|
90
|
-
|
|
91
|
-
Tracks a session with dynamic data. You would call the identity function from the tracker script to save data about the current session.
|
|
92
|
-
|
|
93
|
-
```js
|
|
94
|
-
umami.identify({ email: 'bob@aol.com' });
|
|
95
|
-
```
|
package/src/declarations.d.ts
DELETED
package/src/index.ts
DELETED
package/src/lib/content.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { cache } from 'react';
|
|
2
|
-
import matter from 'gray-matter';
|
|
3
|
-
import recursive from 'recursive-readdir';
|
|
4
|
-
import { firstBy } from 'thenby';
|
|
5
|
-
import fs from 'node:fs/promises';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
|
|
8
|
-
export const getFiles = cache(async (folder: string) => {
|
|
9
|
-
const dir = path.resolve(folder);
|
|
10
|
-
const files = await recursive(dir);
|
|
11
|
-
|
|
12
|
-
return Promise.all(
|
|
13
|
-
files
|
|
14
|
-
.filter((file: string) => path.extname(file) === '.mdx')
|
|
15
|
-
.map(async (file: string) => {
|
|
16
|
-
const postContent = await fs.readFile(file, 'utf8');
|
|
17
|
-
const { data, content } = matter(postContent);
|
|
18
|
-
|
|
19
|
-
const id = file.replace('.mdx', '').replace(dir, '').replace(/\\/g, '/').replace(/^\//, '');
|
|
20
|
-
const anchors: { name: string; id: string; size: number }[] = [];
|
|
21
|
-
const body = content
|
|
22
|
-
.split('\n')
|
|
23
|
-
.map(line => {
|
|
24
|
-
const match = line.match(/(#+)\s+(.*)/);
|
|
25
|
-
if (match) {
|
|
26
|
-
const [, num, name] = match;
|
|
27
|
-
const id = name.toLowerCase().replace(/\s+/g, '-');
|
|
28
|
-
const size = num.length;
|
|
29
|
-
|
|
30
|
-
anchors.push({ name, id, size });
|
|
31
|
-
|
|
32
|
-
return `<h${size} id="${id}">${name.replace(/\{|\}/g, '')}</h${size}>`;
|
|
33
|
-
}
|
|
34
|
-
return line;
|
|
35
|
-
})
|
|
36
|
-
.join('\n');
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
meta: data,
|
|
40
|
-
id,
|
|
41
|
-
body,
|
|
42
|
-
anchors,
|
|
43
|
-
} as any;
|
|
44
|
-
}),
|
|
45
|
-
).then(posts => posts.sort(firstBy('date', 'desc')));
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export async function getFile(id: string, folder: string) {
|
|
49
|
-
const files = await getFiles(folder);
|
|
50
|
-
|
|
51
|
-
return files.find(file => file?.id === id);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export async function getContent(params: { id: string[] }, folder: string) {
|
|
55
|
-
const { id = [] } = params;
|
|
56
|
-
const name = id?.length ? id.join('/') : 'index';
|
|
57
|
-
|
|
58
|
-
return getFile(name, folder);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default getFile;
|
package/src/lib/next.tsx
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Metadata } from 'next';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { Docs } from '@/components/docs/Docs';
|
|
4
|
-
import { Blog } from '@/components/blog/Blog';
|
|
5
|
-
import { getContent } from '@/lib/content';
|
|
6
|
-
import { ShisoConfig } from '@/components/Shiso';
|
|
7
|
-
|
|
8
|
-
const DEFAULT_CONTENT_DIR = './src/content';
|
|
9
|
-
|
|
10
|
-
const components = {
|
|
11
|
-
docs: Docs,
|
|
12
|
-
blog: Blog,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default (config: ShisoConfig) => {
|
|
16
|
-
const { contentDir = DEFAULT_CONTENT_DIR } = config || {};
|
|
17
|
-
|
|
18
|
-
const getMetadata = ({ title }: { title: string }) => {
|
|
19
|
-
return async ({ params }: { params: Promise<{ id: string[] }> }): Promise<Metadata> => {
|
|
20
|
-
const content = await getContent(await params, contentDir);
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
title: {
|
|
24
|
-
absolute: `${content?.meta?.title} – ${title}`,
|
|
25
|
-
default: title,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const renderPage = ({ type }: { type: string }) => {
|
|
32
|
-
const folder = path.resolve(process.cwd(), contentDir, type);
|
|
33
|
-
|
|
34
|
-
return async ({ params }: { params: Promise<{ id: string[] }> }) => {
|
|
35
|
-
const content = await getContent(await params, folder);
|
|
36
|
-
const Component = components[type];
|
|
37
|
-
|
|
38
|
-
return Component && <Component content={content} config={config} />;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
getMetadata,
|
|
44
|
-
renderPage,
|
|
45
|
-
};
|
|
46
|
-
};
|
package/src/lib/types.ts
DELETED
package/src/shiso.config.json
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"contentDir": "./src/content",
|
|
3
|
-
"docs": {
|
|
4
|
-
"title": "Shiso",
|
|
5
|
-
"tabs": [
|
|
6
|
-
{
|
|
7
|
-
"id": "docs",
|
|
8
|
-
"label": "Documentation",
|
|
9
|
-
"url": "/docs"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"id": "components",
|
|
13
|
-
"label": "Components",
|
|
14
|
-
"url": "/docs/components"
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
"navigation": {
|
|
18
|
-
"docs": [
|
|
19
|
-
{
|
|
20
|
-
"group": "Getting started",
|
|
21
|
-
"pages": [
|
|
22
|
-
{
|
|
23
|
-
"label": "Overview",
|
|
24
|
-
"url": "/docs"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"label": "Installation",
|
|
28
|
-
"url": "/docs/installation"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"label": "Configuration",
|
|
32
|
-
"url": "/docs/configuration"
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"group": "Basics",
|
|
38
|
-
"pages": [
|
|
39
|
-
{
|
|
40
|
-
"label": "Writing content",
|
|
41
|
-
"url": "/docs/writing-content"
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
"components": [
|
|
47
|
-
{
|
|
48
|
-
"group": "Components",
|
|
49
|
-
"pages": [
|
|
50
|
-
{
|
|
51
|
-
"label": "Overview",
|
|
52
|
-
"url": "/docs/components"
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
package/tsconfig.build.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"noImplicitAny": false,
|
|
5
|
-
"emitDeclarationOnly": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"allowJs": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"isolatedModules": true,
|
|
11
|
-
"rootDir": "./src",
|
|
12
|
-
"outDir": "./types",
|
|
13
|
-
"module": "esnext",
|
|
14
|
-
"moduleResolution": "bundler",
|
|
15
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
16
|
-
"jsx": "preserve",
|
|
17
|
-
"paths": {
|
|
18
|
-
"@/*": ["./src/*"]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"include": ["src/components/**/*"],
|
|
22
|
-
"exclude": ["node_modules"]
|
|
23
|
-
}
|
|
24
|
-
|
package/tsconfig.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
4
|
-
"dom",
|
|
5
|
-
"dom.iterable",
|
|
6
|
-
"esnext"
|
|
7
|
-
],
|
|
8
|
-
"noImplicitAny": false,
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"noEmit": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"module": "esnext",
|
|
15
|
-
"moduleResolution": "bundler",
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"isolatedModules": true,
|
|
18
|
-
"jsx": "preserve",
|
|
19
|
-
"incremental": true,
|
|
20
|
-
"plugins": [
|
|
21
|
-
{
|
|
22
|
-
"name": "next"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"paths": {
|
|
26
|
-
"@/*": [
|
|
27
|
-
"./src/*"
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
|
-
"target": "ES2017"
|
|
31
|
-
},
|
|
32
|
-
"include": [
|
|
33
|
-
"next-env.d.ts",
|
|
34
|
-
"**/*.ts",
|
|
35
|
-
"**/*.tsx",
|
|
36
|
-
".next/types/**/*.ts"
|
|
37
|
-
],
|
|
38
|
-
"exclude": [
|
|
39
|
-
"node_modules"
|
|
40
|
-
]
|
|
41
|
-
}
|