Skip to content

Commit

Permalink
feat: init default theme doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Oct 7, 2022
1 parent fbb4ed5 commit 2ab6910
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 21 deletions.
49 changes: 37 additions & 12 deletions docs/.island/config.ts
Expand Up @@ -27,8 +27,6 @@ export default defineConfig({
'/zh/': {
lang: 'zh',
label: '简体中文',
selectText: '语言',
ariaLabel: '语言',
lastUpdatedText: '上次更新',
nav: getNavbar('zh'),
sidebar: getSidebar('zh'),
Expand All @@ -46,13 +44,17 @@ export default defineConfig({
'/en/': {
lang: 'en',
label: 'English',
selectText: 'Languages',
ariaLabel: 'Languages',
lastUpdated: 'Last Updated',
nav: getNavbar('en'),
sidebar: getSidebar('en'),
title: 'Island.js',
description: 'SSG Framework based on island architecture'
description: 'SSG Framework based on island architecture',
lastUpdatedText: 'Last Updated',
editLink: {
pattern:
'https://github.com/sanyuan0704/island.js/tree/master/docs/:path',
text: '📝 Edit this page on GitHub'
}
}
},
outlineTitle: 'ON THIS PAGE',
Expand All @@ -62,12 +64,6 @@ export default defineConfig({
link: 'https://github.com/sanyuan0704/island'
}
],
lastUpdatedText: 'Last Updated',
editLink: {
pattern:
'https://github.com/sanyuan0704/island.js/tree/master/docs/:path',
text: '📝 Edit this page on GitHub'
},

footer: {
message: 'Released under the MIT License.',
Expand Down Expand Up @@ -108,7 +104,7 @@ function getSidebar(lang: 'zh' | 'en') {
]
},
{
text: getText('核心功能', 'Features'),
text: getText('基础功能', 'Features'),
items: [
{
text: getText('约定式路由', 'Conventional Routing'),
Expand All @@ -135,6 +131,35 @@ function getSidebar(lang: 'zh' | 'en') {
link: getLink('/guide/extension')
}
]
},
{
text: getText('默认主题功能', 'Default Theme'),
items: [
{
text: getText('导航栏模块', 'Nav Bar'),
link: getLink('/guide/navbar')
},
{
text: getText('Home 页面', 'Home Page'),
link: getLink('/guide/home-page')
},
{
text: getText('API 页面', 'API Page'),
link: getLink('/guide/api-page')
},
{
text: getText('正文页面', 'Doc Page'),
link: getLink('/guide/doc-page')
},
{
text: getText('国际化', 'I18n'),
link: getLink('/guide/i18n')
},
{
text: getText('全文搜索', 'Search'),
link: getLink('/guide/search')
}
]
}
],
[getLink('/api/')]: [
Expand Down
2 changes: 1 addition & 1 deletion docs/en/api/config-theme.md
Expand Up @@ -58,7 +58,7 @@ The sidebar of the site.The config is a object, which

```ts
// The key is the path of the sidebar group
// The value is the sidebar group
// The value is sidebar group array
type Sidebar = Record<string, SidebarGroup[]>;

interface SidebarGroup {
Expand Down
1 change: 1 addition & 0 deletions docs/en/guide/api-page.md
@@ -0,0 +1 @@
# API Page
1 change: 1 addition & 0 deletions docs/en/guide/doc-page.md
@@ -0,0 +1 @@
# Doc Page
1 change: 1 addition & 0 deletions docs/en/guide/home-page.md
@@ -0,0 +1 @@
# Home Page
1 change: 1 addition & 0 deletions docs/en/guide/i18n.md
@@ -0,0 +1 @@
# I18n
77 changes: 77 additions & 0 deletions docs/en/guide/navbar.md
@@ -0,0 +1,77 @@
# NavBar

The nav bar is very important for a website. It allows users to quickly jump between different pages of the website, and also allows users to quickly find some important information on the website.

Island.js default theme has built-in navbar module, you can configure it in `themeConfig.navbar`.

The nav bar is configured as an array, each item in the array is a `NavItem` object, which has the following types:

```ts
export type NavItem = NavItemWithLink | NavItemWithChildren;
```

That is, each navbar element ( `NavItem` ) can be either a link ( `NavItemWithLink` ) or a navbar group with child elements ( `NavItemWithChildren` ).

## NavItemWithLink

```ts
export interface NavItemWithLink {
text: string;
link: string;
activeMatch?: string;
}
```

The meaning of each attribute is as follows:

- `text` - nav item text
- `link` - nav item link
- `activeMatch` - activation rules for navbar links

`activeMatch` is used to match the current route. When the route matches the `activeMatch` rule, the nav item will be highlighted.

> By default, `activeMatch` is the NavItem's `link` property.
## NavItemWithChildren

```ts
export interface NavItemWithChildren {
text: string;
children: NavItem[];
}
```

The meaning of each attribute is as follows:

- `text` - navbar item text
- `children` - child nav items

## Example

```js
import { defineConfig } from 'islandjs';

export default defineConfig({
themeConfig: {
navbar: [
{
text: 'Home',
link: '/',
activeMatch: '^/$|^/'
},
{
text: 'More Pages',
children: [
{
text: 'Github',
link: 'http://github.com/sanyuan0704/island.js',
},
{
text: 'Twitter',
link: 'http://twitter.com/sanyuan0704',
},
}
]
}
});
```
1 change: 1 addition & 0 deletions docs/en/guide/search.md
@@ -0,0 +1 @@
# Search
2 changes: 1 addition & 1 deletion docs/zh/api/config-theme.md
Expand Up @@ -58,7 +58,7 @@ export default defineConfig({

```ts
// key 为 SidebarGroup 的路径
// value 为 SidebarGroup
// value 为 SidebarGroup 的数组
type Sidebar = Record<string, SidebarGroup[]>;

interface SidebarGroup {
Expand Down
1 change: 1 addition & 0 deletions docs/zh/guide/api-page.md
@@ -0,0 +1 @@
# API 页面
1 change: 1 addition & 0 deletions docs/zh/guide/doc-page.md
@@ -0,0 +1 @@
# 正文页面
1 change: 1 addition & 0 deletions docs/zh/guide/home-page.md
@@ -0,0 +1 @@
# Home 页面
3 changes: 3 additions & 0 deletions docs/zh/guide/i18n.md
@@ -0,0 +1,3 @@
# 国际化

Island
77 changes: 77 additions & 0 deletions docs/zh/guide/navbar.md
@@ -0,0 +1,77 @@
# 导航栏模块

导航栏对一个网站来说非常重要,它可以让用户快速的在网站的不同页面之间进行跳转,也可以让用户快速的找到网站的一些重要信息。

Island.js 默认主题内置了导航栏模块,你可以在 `themeConfig.navbar` 中进行配置。

导航栏配置为一个数组,数组中的每一项都是一个 `NavItem` 对象,它具有以下类型:

```ts
export type NavItem = NavItemWithLink | NavItemWithChildren;
```

也就是说,每个导航栏元素( `NavItem` )可以是一个链接( `NavItemWithLink` ),也可以是一个包含子元素的导航栏组( `NavItemWithChildren` )。

## NavItemWithLink

```ts
export interface NavItemWithLink {
text: string;
link: string;
activeMatch?: string;
}
```

其中各项属性的含义如下:

- `text` - 导航栏文本
- `link` - 导航栏链接
- `activeMatch` - 导航栏链接的激活规则

`activeMatch` 用于匹配当前路由,当路由匹配 `activeMatch` 规则时,nav 项会高亮显示。

> 默认情况下,`activeMatch` 是 NavItem 的 `link` 属性。
## NavItemWithChildren

```ts
export interface NavItemWithChildren {
text: string;
children: NavItem[];
}
```

其中各项属性的含义如下:

- `text` - 导航栏文本
- `children` - 子导航栏元素

## 示例

```js
import { defineConfig } from 'islandjs';

export default defineConfig({
themeConfig: {
navbar: [
{
text: 'Home',
link: '/',
activeMatch: '^/$|^/'
},
{
text: '更多链接',
children: [
{
text: 'Github',
link: 'http://github.com/sanyuan0704/island.js',
},
{
text: 'Twitter',
link: 'http://twitter.com/sanyuan0704',
},
}
]
}
});
```
1 change: 1 addition & 0 deletions docs/zh/guide/search.md
@@ -0,0 +1 @@
# 搜索
6 changes: 0 additions & 6 deletions src/shared/types/default-theme.ts
Expand Up @@ -128,12 +128,6 @@ export namespace DefaultTheme {
export interface NavItemWithChildren {
text?: string;
items: NavItemWithLink[];

/**
* `activeMatch` is expected to be a regex string. We can't use actual
* RegExp object here because it isn't serializable
*/
activeMatch?: string;
}

// image -----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/theme-default/components/Nav/index.module.scss
Expand Up @@ -25,7 +25,7 @@
}

@media (min-width: 960px) {
.has-sidebar .content {
.content {
margin-right: -32px;
padding-right: 32px;
-webkit-backdrop-filter: saturate(50%) blur(8px);
Expand Down

1 comment on commit 2ab6910

@vercel
Copy link

@vercel vercel bot commented on 2ab6910 Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.