This repository is a reusable documentation template built on the current docs shell from the Tonconsole docs codebase.
It keeps the existing visual design, layout, and overall UX, but moves shell-level concerns into centralized configuration so future projects can adopt the template without rewriting theme files for every new site.
For repository-native content authoring guidance, see AUTHORING.md.
For starter-content migration guidance, see ADOPTION.md.
For upstream maintenance workflow, see UPSTREAM.md.
- Static documentation site built with Next.js, Nextra, and MDX
- Centralized shell configuration in
site.config.ts - Template-owned shell branding assets in
public/brand/ - File-based navigation and content in
pages/**with_meta.json - Reusable MDX primitives for callouts, code tabs, spoilers, and OpenAPI-backed sections
- Static export workflow for GitHub Pages or other static hosting targets
next@13nextra@2nextra-theme-docs- React 18
- MDX pages via the
pages/router - Static export to
dist/
Use a current Node.js LTS release. Node 18+ is the safest baseline for this repository.
npm ci
cp .env.example .env.local
npm run devThe local dev server starts on the default Next.js port.
npm run buildThis builds the site and exports static files to dist/.
This is the practical layout you will work with most often:
site.config.ts Central shell configuration
theme.config.tsx Nextra theme wiring for logo, metadata, footer, TOC CTA, edit links
next.config.js Next.js + Nextra config, including GitHub Pages deploy behavior
.env.example Environment-facing overrides for OpenAPI and GitHub Pages
pages/ Documentation pages and navigation structure
pages/_meta.json Top-level sidebar/navigation labels
pages/**/_meta.json Nested section labels, ordering, and hidden items
pages/**/*.mdx Page content
examples/ Reusable MDX code snippets imported into pages
components/ Custom MDX/UI primitives used by docs pages
utils/ Helpers for links and OpenAPI data loading
.github/workflows/ GitHub Actions deployment workflow
public/brand/ Template-owned shell brand assets
public/assets/ Content assets used by docs pages
public/robots.txt Static robots file
The main template entry point is site.config.ts.
Use this file for shell-level settings only:
- Site identity: site name, title suffix, base URL, locale
- SEO metadata: description, keywords, Open Graph, Twitter metadata
- Community links: header chat link, support/contact links, TOC CTA
- Repository links: project URL, edit link base, issues/feedback link
- Footer links and labels
- Analytics and verification values
- GitHub Pages deploy defaults
- OpenAPI source URLs
- Shell brand asset paths
Current top-level config sections:
siteseoverificationcommunityrepositoryfooteranalyticsdeploy.githubPagesopenApibrand
Keep product copy, tutorials, API explanations, and section content out of site.config.ts. That content belongs in MDX pages under pages/.
Optional integrations such as analytics and verification can be disabled by setting their values to null in site.config.ts.
Shell-owned branding files live in public/brand/:
favicon.icoicon.svgapple-touch-icon.pngicon-192.pngicon-512.pngmanifest.jsonog-image.png
To rebrand the template:
- Replace the files in
public/brand/with your own assets. - Update the
brandsection insite.config.tsonly if file names or paths change. - Update shell text and metadata in
site.config.ts.
Do not move page-specific screenshots, videos, diagrams, or other doc content into public/brand/. Those assets should stay content-local in public/assets/ or another content-oriented location.
This repository uses the Next.js pages/ router and Nextra's file-based docs model.
- Every
.mdxfile underpages/becomes a route. - Each section can define a
_meta.jsonfile to control labels and ordering. - Nested folders become nested docs sections.
- Hidden routes are declared in
_meta.jsonwith"display": "hidden".
Example:
pages/tonapi/rest-api/accounts.mdxbecomes/tonapi/rest-api/accountspages/tonapi/rest-api/_meta.jsoncontrols the sidebar labels and order for that section
- Create a new
.mdxfile in the correct folder underpages/. - Add the page key to the nearest
_meta.json. - Give the page an
# H1heading. - Import any MDX components you need.
Update the relevant _meta.json file:
- Top-level sections:
pages/_meta.json - Nested sections:
pages/**/_meta.json
Most day-to-day authoring should happen in MDX files under pages/.
Use MDX for:
- Page body copy
- Guides and tutorials
- Product/API explanations
- Tables, lists, and headings
- Embedded reusable components
- Code examples imported from
examples/
Use site.config.ts for:
- Site-wide shell settings
- Metadata and social links
- Footer and repository links
- Brand asset paths
- Deploy/OpenAPI defaults
This distinction is intentional: shell behavior is centralized, but documentation content remains normal MDX.
The template already includes a small set of authoring primitives in components/.
Pages use Nextra's built-in Callout component:
import { Callout } from 'nextra-theme-docs';
<Callout type="info" emoji="ℹ️">
Important note.
</Callout>The current docs use info and warning variants, but you can use any variant supported by nextra-theme-docs.
Use ExampleTabs and ExampleTab to switch between multiple examples on the same page:
import { ExampleTabs, ExampleTab } from '@/components';
<ExampleTabs>
<ExampleTab label="TypeScript">Content here</ExampleTab>
<ExampleTab label="Python">Content here</ExampleTab>
</ExampleTabs>These are typically paired with snippet files from examples/.
Use Spoiler for collapsible supporting content:
import { Spoiler } from '@/components';
<Spoiler title="Glossary">Hidden content here</Spoiler>Use ExternalLink when you want a consistent external-link wrapper:
import { ExternalLink } from '@/components';
<ExternalLink href="https://example.com">External resource</ExternalLink>The repo includes a pattern for REST/API pages backed by an OpenAPI schema:
loadStaticinutils/schemas.tsfetches the configured schema at build timeSchemaLoaderrenders operations for a given tagSwaggerLinklinks the page heading to the corresponding Swagger UI section
Typical pattern:
import { SwaggerLink, SchemaLoader } from '@/components';
import { SWAGGER_TAGS } from '@/constants';
import { loadStatic } from '@/utils';
export const getStaticProps = loadStatic;
# Accounts<SwaggerLink tag={SWAGGER_TAGS.ACCOUNTS} />
<SchemaLoader tag={SWAGGER_TAGS.ACCOUNTS} />If you do not need OpenAPI-backed pages for your project, you can leave those sections unused and keep the rest of the template as a standard MDX docs site.
The examples/ directory contains MDX snippet files that can be imported into multiple pages.
Use it for:
- Shared code samples
- Multi-language snippets
- Repeated instructional blocks
This keeps large example blocks out of page files and avoids duplication across related docs.
Start from .env.example:
cp .env.example .env.localCurrent environment-facing settings:
NEXT_PUBLIC_TONAPI_LANDING_PAGE_URLNEXT_PUBLIC_TONAPI_OPENAPI_JSON_URLNEXT_PUBLIC_TONAPI_OPENAPI_YAML_URL- Optional
NEXT_PUBLIC_GITHUB_PAGES_*overrides
These values currently support the existing OpenAPI-backed docs and GitHub Pages deployment path.
The main build command exports a static site:
npm run buildOutput goes to dist/.
This makes the template suitable for static hosting platforms that can serve prebuilt files.
The repository includes a GitHub Actions workflow for GitHub Pages at .github/workflows/deploy-pages.yml.
The workflow:
- enables
GHPAGES=1 - derives
NEXT_PUBLIC_GITHUB_PAGES_*from the current repository name - uses
/automatically for<owner>.github.iorepositories and/<repo>for project pages - runs
npm ciandnpm run build - uploads
dist/as the Pages artifact and adds.nojekyllso exported Next.js assets under_next/are served correctly
To use it:
- Enable GitHub Pages in the repository settings and choose
GitHub Actionsas the source. - Push to
masterormain, or run the workflow manually from the Actions tab.
The repository also keeps a manual GitHub Pages build path:
npm run gh-deployThat command enables GHPAGES=1, builds the site, exports it, and publishes dist/ directly.
GitHub Pages-related defaults are aligned between site.config.ts, next.config.js, and .env.example:
NEXT_PUBLIC_GITHUB_PAGES_REPO_NAMENEXT_PUBLIC_GITHUB_PAGES_BASE_PATHNEXT_PUBLIC_GITHUB_PAGES_ASSET_PREFIXNEXT_PUBLIC_GITHUB_PAGES_TRAILING_SLASH
Override these only if your published path differs from the default repository-based path.
For a new project, the usual setup order is:
- Update
site.config.tswith your site name, metadata, links, and repository values. - Replace shell assets in
public/brand/. - Update top-level navigation in
pages/_meta.json. - Replace or reorganize the starter MDX content under
pages/. - Add or remove sections by editing
pages/**and_meta.json. - Update
.env.localif you use different OpenAPI or deploy settings. - Run
npm run buildbefore publishing.
- Keep shell concerns centralized in
site.config.ts. - Keep page content in MDX.
- Keep shell brand files in
public/brand/. - Keep content assets separate from shell assets.
- Avoid changing framework, router, or docs engine unless there is a strong compatibility reason.
- Prefer thin changes that preserve upstream mergeability.