styledsea

Page

A page in your documentation

Page is the base element of a documentation, it includes Table of contents, Footer, and Breadcrumb.

Usage

import {
  DocsPage,
  DocsDescription,
  DocsTitle,
  DocsBody,
} from 'styledsea-docs-interface/page';
 
<DocsPage>
  <DocsTitle>title</DocsTitle>
  <DocsDescription>description</DocsDescription>
  <DocsBody>...</DocsBody>
</DocsPage>;

Page

The main layout of docs pages.

Title

Page title.

Description

Page description.

Body

It applies the Typography styles, wrap your content inside.

You can use this component without <DocsPage />.

import { DocsBody } from 'styledsea-docs-interface/page';
 
<DocsBody>
  <h1>This heading looks good!</h1>
</DocsBody>;

Category

Optional, display the other pages in its folder.

You can use this component without <DocsPage />.

import { DocsPage, DocsCategory } from 'styledsea-docs-interface/page';
import { getPages } from '@/lib/source';
 
<DocsPage>
  <DocsCategory page={page} pages={getPages()} />
</DocsPage>;

Configurations

Full Mode

To extend the page to fill up all available space, pass full to the page component. This will force TOC to be shown as a popover.

import { DocsPage } from 'styledsea-docs-interface/page';
 
<DocsPage full>...</DocsPage>;

Table of Contents

An overview of all the headings in your document.

It requires an array of headings. For Markdown and MDX documents, You can obtain it using the TOC Utility. Content sources like Adalt MDX offer this out-of-the-box.

import { DocsPage } from 'styledsea-docs-interface/page';
 
<DocsPage toc={headings}>...</DocsPage>;

Options

Customise or disable TOC from your documentation with the tableOfContent option.

import { DocsPage } from 'styledsea-docs-interface/page';
 
<DocsPage tableOfContent={options}>...</DocsPage>;
PropTypeDefault
header
ReactNode
-
footer
ReactNode
-
single
boolean
true
enabled
boolean
-
component
ReactNode
-
style
"normal" | "clerk"
'normal'

Popover Mode

On smaller devices, it is shown on a popover instead. Customise it with the tableOfContentPopover option.

import { DocsPage } from 'styledsea-docs-interface/page';
 
<DocsPage tableOfContentPopover={options}>...</DocsPage>;
PropTypeDefault
header
ReactNode
-
footer
ReactNode
-
enabled
boolean
-
component
ReactNode
-
style
"normal" | "clerk"
'normal'

Last Updated Time

Display last updated time of the page.

import { DocsPage } from 'styledsea-docs-interface/page';
 
<DocsPage lastUpdate={new Date(lastModifiedTime)} />;

Since you might have different version controls (e.g. Github) or it's from remote sources like Sanity, Adalt UI doesn't display the last updated time by default.

For Github hosted documents, you can use the getGithubLastEdit utility.

import { DocsPage } from 'styledsea-docs-interface/page';
import { getGithubLastEdit } from 'styledsea-docs-core/server';
 
const time = await getGithubLastEdit({
  owner: 'styledsea',
  repo: 'adalt',
  path: `content/docs/${page.file.path}`,
});
 
<DocsPage lastUpdate={new Date(time)} />;

Note

You can also manually specify the last updated time of documents (e.g. using frontmatter). Don't forget to update the schema type on Adalt MDX.

Edit on GitHub

A shortcut to add "Edit on GitHub" button to TOC footer.

import { DocsPage } from 'styledsea-docs-interface/page';
 
<DocsPage
  editOnGithub={{
    owner: 'styledsea',
    repo: 'adalt',
    sha: 'main',
    // file path, make sure it's valid
    path: `content/docs/${page.file.path}`,
  }}
/>;

Footer is a navigation element that has two buttons to jump to the next and previous pages. When not specified, it shows the neighbour pages found from page tree.

Customise the footer with the footer option.

import { DocsPage, DocsBody } from 'styledsea-docs-interface/page';
 
<DocsPage footer={options}>
  <DocsBody>...</DocsBody>
</DocsPage>;
PropTypeDefault
enabled
boolean
-
component
ReactNode
-
items
{ previous?: { name: string; url: string; } | undefined; next?: { name: string; url: string; } | undefined; }
-

A navigation element, shown only when user is navigating in folders.

PropTypeDefault
enabled
boolean
-
component
ReactNode
-
full
boolean
false
includeRoot
boolean | { url: string; }
false
includeSeparator
boolean
false

MDX Page

In conjunction of Adalt MDX, you may create a page.mdx file and add the following.

export { withArticle as default } from 'styledsea-docs-interface/page';
 
## Hello World

This creates a page with MDX, with proper typography styles applied.

Last updated on

On this page

Edit on GitHub