Skip to content

Commit f22c3a6

Browse files
committed
feat: add configure-site doc
1 parent 0d01e1b commit f22c3a6

File tree

17 files changed

+457
-36
lines changed

17 files changed

+457
-36
lines changed

.github/contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ $ pnpm run dev
4242
And then you can execute:
4343

4444
```sh
45-
$ pnpm run docs:dev
45+
$ pnpm run dev:docs
4646
```
4747

4848
Visit http://localhost:5173 and try modifying the source code. You'll get live update.

docs/.island/config.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from '../../dist';
22

33
export default defineConfig({
44
lang: 'en-US',
5+
title: '666',
56
icon: '/icon.png',
67
themeConfig: {
78
socialLinks: [
@@ -29,13 +30,18 @@ export default defineConfig({
2930
function getTutorialSidebar() {
3031
return [
3132
{
32-
text: 'Guide',
33-
items: [{ text: 'Getting Started', link: '/guide/getting-started' }]
33+
text: 'Introduction',
34+
items: [
35+
{ text: 'Getting Started', link: '/guide/getting-started' },
36+
{ text: 'Configure Your Site', link: '/guide/configure-site' }
37+
]
38+
},
39+
{
40+
text: 'Concepts',
41+
items: [
42+
{ text: 'SPA vs MPA', link: '/guide/spa-vs-mpa' },
43+
{ text: 'Islands Architecture', link: '/guide/islands-arch' }
44+
]
3445
}
35-
36-
// {
37-
// text: 'Advance',
38-
// items: []
39-
// }
4046
];
4147
}

docs/guide/configure-site.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Configure your Site
2+
3+
## Create config file
4+
5+
Without any configuration, the page is pretty minimal, which has no navigation and no sidebar.However, you can configure the site by `.island/config.ts` file and custom your own site.
6+
7+
For example, in the initial project created by previous guide, you can add the config file and the project structure will be like this:
8+
9+
```bash
10+
.
11+
├─ docs
12+
│ ├─ .island
13+
│ │ └─ config.ts
14+
│ └─ index.md
15+
└─ package.json
16+
```
17+
18+
You can try to add the following config code in `config.ts`:
19+
20+
```ts
21+
import { defineConfig } from 'islandjs';
22+
23+
export default defineConfig({
24+
title: 'my-site'
25+
});
26+
```
27+
28+
There are some tips for the config file:
29+
30+
- 1. Island.js support `.js``.ts``.mjs``.cjs` file as config file.However, it is recommended to use TypeScript config because you can use `defineConfig` to get type hint.
31+
32+
- 2. config file should has a default export, which is a `SiteConfig` object.
33+
34+
In above example, we set the `title` of the site to `my-site`, then you can run start the dev server by `yarn dev:docs`.You will see the title of the site has been changed to `my-site`.This means you have awake your first site config, wonderful!
35+
36+
In next section, we will introduce nav and sidebar config, which is very important for a doc site.
37+
38+
## Nav config
39+
40+
The nav config is used to config the navigation of the site, which has following structure:
41+
42+
```ts
43+
import { defineConfig } from 'islandjs';
44+
45+
export default defineConfig({
46+
themeConfig: {
47+
nav: [
48+
{
49+
text: 'Home',
50+
link: '/',
51+
activeMatch: '^/$|^/'
52+
}
53+
]
54+
}
55+
});
56+
```
57+
58+
It should be noticed that the `nav` config is under `themeConfig`, and belongs to the default theme of Island.js.
59+
60+
The `nav` config is an array of `NavItem`, which has following type:
61+
62+
```ts
63+
interface NavItem {
64+
// The text of the nav item
65+
text: string;
66+
// The link href will be entered when click the nav item
67+
link: '/';
68+
// The active match rule of the nav item
69+
activeMatch: '^/$|^/';
70+
}
71+
```
72+
73+
The `activeMatch` is used to match the current route, and the nav item will be highlighted when the route matches the `activeMatch` rule.
74+
75+
## Sidebar config
76+
77+
The sidebar config is used to config the sidebar of the site, which has following structure:
78+
79+
```ts
80+
import { defineConfig } from 'islandjs';
81+
82+
export default defineConfig({
83+
themeConfig: {
84+
sidebar: [
85+
{
86+
text: 'Guide',
87+
items: [
88+
{
89+
text: 'Getting Started',
90+
link: '/guide/getting-started'
91+
}
92+
]
93+
}
94+
]
95+
}
96+
});
97+
```
98+
99+
The `sidebar` config is also under `themeConfig`, and belongs to the default theme of Island.js.
100+
101+
`sidebar` config has two form: `array` and `object`.
102+
103+
The `array` config is a list of `SidebarGroup`, which has following type:
104+
105+
```ts
106+
interface SidebarGroup {
107+
// The text of the sidebar group
108+
text: string;
109+
// The child items of the sidebar group
110+
items: SidebarItem[];
111+
// Whether the sidebar group is collapsible
112+
collapsible?: boolean;
113+
// The initial state of the sidebar group, which is only valid when `collapsible` is true
114+
collapsed?: boolean;
115+
}
116+
```
117+
118+
The `object` config is a map for `SidebarGroup`, which has following type:
119+
120+
```ts
121+
Record<string, SidebarGroup>;
122+
```

docs/guide/getting-started.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
## Why Island.js?
44

5-
🏝️ Island.js is a static site generator that builds on top of Vite and Mdx. It is designed to be simple, powerful, and performant. It is built to help you focus on writing and deployed with minimum configuration.It has the following features:
5+
🏝️ Island.js is a static site generator that builds on top of Vite, React and Mdx. It is designed to be simple, powerful, and performant. It is built to help you focus on writing and deployed with minimum configuration.It has the following features:
66

77
- **Fast**: Island is built on top of Vite, which is a modern build tool that aims to provide a faster and leaner development experience.
88
- **Flexible**: It has internal Mdx language support, which is a powerful way to write content. You can write, import and use React components in Markdown file.
99
- **Performant**: It is designed to be [island architecture](https://jasonformat.com/islands-architecture/), which means less javascript bundle, partial hydration and better performance about FCP, TTI.
1010

11-
## Quick Start
11+
Next we will walk you through the steps to create a new Island.js doc site.
1212

13-
### 1. Init project
13+
## 1. Init project
1414

1515
First, you can use create a new directory by following command:
1616

@@ -48,7 +48,7 @@ And then you can add the following scripts in `package.json`:
4848
}
4949
```
5050

51-
### 2. Start dev server
51+
## 2. Start dev server
5252

5353
Serve the documentation site in the local server.
5454

@@ -58,7 +58,7 @@ yarn dev
5858

5959
Island will start a development server at http://localhost:5173.
6060

61-
### 3. Build for production
61+
## 3. Build for production
6262

6363
Build the documentation site for production.
6464

@@ -68,7 +68,7 @@ yarn build
6868

6969
Island will generate a static site in the `.island/dist` directory.
7070

71-
### 4. Preview locally
71+
## 4. Preview locally
7272

7373
Preview the production build locally.
7474

docs/guide/islands-arch.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Islands architecture
2+
3+
TODO

docs/guide/spa-vs-mpa.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPA vs MPA
2+
3+
TODO

docs/guide/what-is-island-js.md

Whitespace-only changes.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"unified": "^10.1.2",
8888
"unist-util-visit": "^4.1.1",
8989
"unist-util-visit-children": "^2.0.0",
90-
"vite": "3.1",
90+
"vite": "3.0",
9191
"vite-plugin-inspect": "^0.7.1"
9292
},
9393
"devDependencies": {

0 commit comments

Comments
 (0)