The theme config is under the themeConfig
in root config. For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
// ...
}
});
Array
[]
The navigation bar of the site. The nav
config is an array of NavItem
, which has following type:
interface NavItem {
// The text of the nav item
text: string;
// The link href will be entered when click the nav item
link: '/';
// The active match rule of the nav item, optional
activeMatch: '^/$|^/';
}
The activeMatch
is used to match the current route, and the nav item will be highlighted when the route matches the activeMatch
rule.By default, the activeMatch
is the link
of the nav item.
For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
nav: [
{
text: 'Home',
link: '/',
activeMatch: '^/$|^/'
}
]
}
});
And you can also use the NavGroup config in nav
array, which has following type:
interface NavGroup {
// The text of the nav group
text: string;
// The children of the nav group
items: NavItem[];
}
For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
nav: [
{
text: 'Home',
items: [
{
text: 'Menu 1',
link: '/menu1'
},
{
text: 'Menu 2',
link: '/menu2'
}
]
}
]
}
});
Object
The sidebar of the site.The config is a object, which
// The key is the path of the sidebar group
// The value is sidebar group array
type Sidebar = Record<string, SidebarGroup[]>;
interface SidebarGroup {
// The text of the sidebar group
text: string;
// The child items of the sidebar group
items: SidebarItem[];
// Whether the sidebar group is collapsable, optional
collapsable?: boolean;
// The initial collapsed state of the sidebar group, optional
collapsed?: boolean;
}
type SidebarItem = {
// The text of item
text: string;
// The link href of item
link: string;
};
For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
sidebar: {
'/guide/': [
{
text: 'Guide',
items: [
{
text: 'Getting Started',
link: '/guide/getting-started'
}
]
}
]
}
}
});
Object
| undefined
undefined
The edit link of the site.If it's undefined, the edit link feature will be disabled.
The editLink
config is an object of EditLink
, which has following type:
export interface EditLink {
// Pattern for edit link.
pattern: string;
// Custom text for edit link.
text?: string;
}
For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
editLink: {
pattern:
'https://github.com/sanyuan0704/island.js/tree/master/docs/:path',
text: '📝 Edit this page on GitHub'
}
}
});
:path
will be replaced by the current page path.
string
"Last Updated"
The text of last updated time.
For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
lastUpdatedText: 'Last Updated'
}
});
Object
{}
The footer of the home site.
The footer
config is an object of Footer
, which has following type:
export interface Footer {
message?: string;
copyright?: string;
}
For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
footer: {
message: 'Powered by Island.js',
copyright: `© ${new Date().getFullYear()} Island.js`
}
}
});
Array
[]
The social links of the site.
The socialLinks
config is an array of SocialLink
, which has following type:
export interface SocialLink {
icon: SocialLinkIcon;
link: string;
}
For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
socialLinks: [
{
icon: 'github',
link: 'https://github.com/sanyuan0704/island'
}
]
}
});
In current version, the
icon
only supportsgithub
.
string
Configure the title of the outline in the right sidebar.
For example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
outlineTitle: 'ON THIS PAGE'
}
});
string
Previous Page
The text of the previous page. for example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
prevPageText: 'Previous Page'
}
});
string
Next Page
Text for the next page. for example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
nextPageText: 'Next Page'
}
});
Object
undefined
I18n config. This config is an object, the key is the routing prefix of the corresponding language (such as /en
), the value is LocaleConfig
, the type is as follows:
export interface LocaleConfig {
// language name
lang?: string;
// HTML title
title?: string;
// HTML description
description?: string;
// Display text in corresponding language
label: string;
// Navbar config, of the same type as `themeConfig.nav`
nav?: NavItem[];
// Sidebar config, of the same type as `themeConfig.sidebar`
sidebar?: Sidebar;
// Outline title
outlineTitle?: string;
// The text of the last updated time
lastUpdatedText?: string;
// The text of the edit link
editLink?: EditLink;
// The text of the prev page
prevPageText?: string;
// The text of the next page
nextPageText?: string;
}
As you see, there are many fields in themeConfig
that can be also configured in LocaleConfig
, including:
But the LocaleConfig
has higher priority.So it will override the corresponding field in themeConfig
.
boolean
true
Whether to enable search.You can disable it by setting it to false
:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
search: false
}
});
object | boolean
true
Whether to enable back top.You can disable it by setting it to false
:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
backTop: false
}
});
Provide an object config can use more detailed functions, for example:
import { defineConfig } from 'islandjs';
export default defineConfig({
themeConfig: {
visibleHeight: 200, // number,backtop button visible height
duration: 500, // number, back to top duration
animation: 'quadIn' // string,back to top animation
}
});
We support the following animation:
type BackTopAnimation =
| 'linear'
| 'quadIn'
| 'quadOut'
| 'quadInOut'
| 'cubicIn'
| 'cubicOut'
| 'cubicInOut'
| 'quartIn'
| 'quartOut'
| 'quartInOut'
| 'quintIn'
| 'quintOut'
| 'quintInOut'
| 'sineIn'
| 'sineOut'
| 'sineInOut'
| 'bounceIn'
| 'bounceOut'
| 'bounceInOut';
Experience different animations with the following components: