Skip to content

kolasokol/tk-doc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TK Doc

TK Doc home page TK Doc documentation page

A modern, high-performance documentation platform built with Next.js 16 and MDX

Next.js React TypeScript Tailwind CSS Docker pnpm

Website PRs Welcome GitHub last commit GitHub license

Features β€’ Quick Start β€’ Documentation β€’ Project Structure β€’ Contributing


πŸ“– Overview

TK Doc is a production-ready documentation template designed for developers who need a fast, beautiful, and maintainable documentation site. Built with cutting-edge technologies, it provides an exceptional reading experience while maintaining excellent developer experience.

Perfect for technical documentation, API references, knowledge bases, and developer guides.

✨ Features

πŸš€ Performance & Modern Stack

  • Next.js 16 with App Router for optimal performance
  • React 19 with Server Components
  • TypeScript for type safety
  • Tailwind CSS 4 for modern styling
  • pnpm for fast, efficient package management

πŸ“ Content Management

  • MDX Support - Write docs in Markdown with React components
  • Frontmatter - Metadata support for title, description, and tags
  • Code Highlighting - Beautiful syntax highlighting with Prism
  • Auto-generated Sidebar - Automatic navigation from folder structure
  • Table of Contents - Automatic heading extraction

🎨 UI Components

  • 30+ Pre-built Components - Accordion, Alert, Badge, Card, Tabs, and more
  • Organized Structure - Components organized by category (buttons, forms, modals)
  • PascalCase Naming - React-consistent naming conventions for easy identification
  • Radix UI Primitives - Accessible, unstyled components
  • Responsive Design - Mobile-first approach
  • Custom Fonts - Inter for text, JetBrains Mono for code
  • Performance Optimized - Dynamic imports for non-critical components

πŸŒ— Dark Mode

  • System-Aware Theme - Automatically follows your OS preference via next-themes
  • Theme Toggle - Sun/Moon toggle button in the header for manual switching
  • Full Coverage - Dark mode styles across all components, sidebar, search, code blocks, and more

πŸ” Enhanced UX

  • Command Palette - Quick search with Cmd+K / Ctrl+K
  • Keyboard Shortcuts - Press ? to view all available keyboard shortcuts
  • Back to Top - Floating button appears on scroll for quick navigation
  • Click-to-Copy Inline Code - Click any inline code snippet to copy it to clipboard
  • Related Articles - Tag-based related content suggestions at the bottom of each page
  • Social Sharing - Share buttons for Twitter, Bluesky, LinkedIn, WhatsApp, Email, and copy link
  • Responsive Table of Contents - Collapsible mobile-friendly TOC with active heading tracking
  • RSS Feed - Auto-generated RSS feed at /feed.xml from all MDX content
  • SEO Optimized - Meta tags, OpenGraph, Twitter cards, JSON-LD structured data
  • Security Headers - HSTS, CSP, X-Frame-Options configured
  • Sitemap Generation - Automatic sitemap for better indexing

πŸ› οΈ Developer Experience

  • Hot Reload - Instant feedback during development
  • ESLint - Code quality checks
  • TypeScript Strict Mode - Maximum type safety
  • Component Examples - View all available components

πŸš€ Quick Start

Prerequisites

  • Node.js 18.17 or higher
  • pnpm (recommended) or npm/yarn

Installation

  1. Use this template or clone:

    git clone https://github.com/kolasokol/tk-doc.git
    cd tk-doc
  2. Install dependencies:

    pnpm install
  3. Start the development server:

    pnpm dev
  4. Open your browser:

    Navigate to http://localhost:3000

Build for Production

pnpm build
pnpm start

πŸ“š Documentation

Creating Your First Page

The template includes one example file: component-examples.mdx showing all available components.

To add your own content:

  1. Create a new .mdx file in the content/ directory (or in a subfolder):
---
title: Getting Started
description: Learn how to use TK Doc
tags: [guide, beginner]
---

# Getting Started

Welcome to your documentation site!

## Installation

Install the package:

```bash
npm install your-package
```

<Alert>
  <AlertTitle>Note</AlertTitle>
  <AlertDescription>
    This is an example of using components in MDX.
  </AlertDescription>
</Alert>
  1. The page will automatically appear in the sidebar based on the folder structure
  2. Organize pages into folders for better navigation (e.g., content/guides/getting-started.mdx)
  3. You can safely remove component-examples.mdx once you're familiar with the components

Using Components

All UI components are available in MDX files. See the complete list with examples:

πŸ‘‰ View Component Examples

<Tabs defaultValue="npm">
  <TabsList>
    <TabsTrigger value="npm">npm</TabsTrigger>
    <TabsTrigger value="pnpm">pnpm</TabsTrigger>
  </TabsList>
  <TabsContent value="npm">```bash npm install package ```</TabsContent>
  <TabsContent value="pnpm">```bash pnpm add package ```</TabsContent>
</Tabs>

Organizing Content

The content/ folder starts with only one file:

content/
└── component-examples.mdx    # Component showcase & reference

To add your documentation:

  1. Create folders for different sections (e.g., guides/, api/, tutorials/)
  2. Add .mdx files inside these folders
  3. The sidebar navigation will be auto-generated from your folder structure

Example structure you might create:

content/
β”œβ”€β”€ component-examples.mdx    # Keep this as reference
β”œβ”€β”€ getting-started/
β”‚   β”œβ”€β”€ installation.mdx
β”‚   └── quick-start.mdx
β”œβ”€β”€ guides/
β”‚   β”œβ”€β”€ authentication.mdx
β”‚   └── deployment.mdx
└── api/
    └── reference.mdx

Each folder becomes a section in the sidebar, and files within become pages.

Configuring Your Site

Site configuration uses a 3-layer approach for smooth updates:

We separate defaults, production overrides, and optional local changes:

  • config/config.base.ts – Template defaults (do not modify)
  • config/config.private.ts – Committed, production overrides (domain, analytics, socials)
  • config/config.local.ts – Gitignored, dev-only overrides (optional)
  • config/site.ts – Aggregator that merges Base β†’ Private β†’ Local

This keeps updates simple and hosting predictable, with zero surprises.

Quick Configuration

  1. Copy the example local file (optional, for dev):
cp config/config.local.example.ts config/config.local.ts
  1. Edit config/config.private.ts for production settings, and config/config.local.ts for dev-only overrides:
import type { BaseSiteConfig } from "./config.base";

export const privateConfig: Partial<BaseSiteConfig> = {
  // Basic Information
  name: "Your Site Name",
  title: "Your Site Title",
  description: "Your site description",
  url: "https://yourdomain.com",

  // Social Media Links (set to empty string "" to hide)
  social: {
    github: "https://github.com/yourusername",
    twitter: "https://twitter.com/yourusername",
    linkedin: "https://linkedin.com/in/yourusername",
  },

  // Twitter/X Card Configuration
  twitter: {
    card: "summary_large_image",
    creator: "@yourtwitterhandle",
  },

  // Open Graph Image (for social sharing)
  og: {
    image: "/og-image.png",
    imageWidth: 1200,
    imageHeight: 630,
  },

  // Google Analytics
  analytics: {
    googleAnalyticsId: "G-XXXXXXXXXX", // Add your GA4 ID
  },

  // Footer Branding
  footer: {
    companyName: "YourCompany",
  },
};

Note: You only need to specify fields you want to override. Unspecified fields use defaults from config.base.ts. Dev-only changes go in config.local.ts.

Why This Approach?

  • Clean separation - Base defaults stay intact, your changes are isolated
  • Easy updates - Update the template without losing your customizations
  • Type safety - TypeScript ensures your overrides match the base config
  • Git-friendly - config.local.ts is gitignored; config.private.ts is committed for predictable hosting

Configuration Fields Explained

Field Purpose Example
name Company/site name "TK Doc"
title Page title (appears in browser tab) "TK Doc"
description Meta description (SEO) "A modern documentation platform"
url Your production domain "https://docs.example.com"
social.github GitHub profile link Leave empty "" to hide
social.twitter Twitter profile link Leave empty "" to hide
social.linkedin LinkedIn profile link Leave empty "" to hide
twitter.creator Twitter handle for cards "@yourhandle"
og.image Social sharing image Must be in /public folder

What Changes When You Update Config

βœ… Site title - Browser tab, metadata, social cards
βœ… Site description - Meta tags, SEO, social sharing
βœ… Social links - Header and footer links
βœ… Sitemap & Robots - Generated with your domain
βœ… Footer text - Company name in copyright
βœ… OG Image - Used when shared on social media

πŸ’‘ Tip: After updating config/config.private.ts or config/config.local.ts, restart your dev server for changes to take effect.

Example: White-Label for a Client

Edit config/config.private.ts with client-specific overrides:

import type { BaseSiteConfig } from "./config.base";

export const privateConfig: Partial<BaseSiteConfig> = {
  name: "Client Inc",
  title: "Client Inc Documentation",
  description: "Official documentation for Client Inc products",
  url: "https://docs.clientinc.com",

  social: {
    github: "https://github.com/clientinc",
    twitter: "https://twitter.com/clientinc",
    linkedin: "https://linkedin.com/company/clientinc",
  },

  twitter: {
    card: "summary_large_image",
    creator: "@clientinc",
  },

  og: {
    image: "/og-image.png",
  },

  footer: {
    companyName: "Client Inc",
  },
} as const;

That's it! All branding updates instantly across the entire site.

Analytics (Google Analytics)

Add your GA4 Measurement ID in config/config.private.ts (production) or leave empty in config/config.local.ts (dev):

export const privateConfig: Partial<BaseSiteConfig> = {
  // ... other config
  analytics: {
    googleAnalyticsId: "G-XXXXXXXXXX", // Replace with your GA4 ID
  },
};
  • The ID is read by components/analytics.tsx and injected globally from app/layout.tsx
  • Leave googleAnalyticsId empty to disable Google Analytics automatically
  • Restart dev server or redeploy after updating the ID

πŸ“ Project Structure

tk-doc/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ layout.tsx               # Root layout with sidebar & dynamic imports
β”‚   β”œβ”€β”€ page.tsx                 # Homepage
β”‚   β”œβ”€β”€ globals.css              # Global styles
β”‚   β”œβ”€β”€ docs/
β”‚   β”‚   └── [...slug]/           # Dynamic MDX routes
β”‚   β”œβ”€β”€ feed.xml/
β”‚   β”‚   └── route.ts             # RSS feed generation
β”‚   └── ui/
β”‚       β”œβ”€β”€ search.tsx           # Search component
β”‚       └── interface/           # Layout components
β”œβ”€β”€ components/                   # React components
β”‚   β”œβ”€β”€ ui/                      # Radix UI components (PascalCase)
β”‚   β”‚   β”œβ”€β”€ Accordion.tsx
β”‚   β”‚   β”œβ”€β”€ Alert.tsx
β”‚   β”‚   β”œβ”€β”€ Badge.tsx
β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”œβ”€β”€ Card.tsx
β”‚   β”‚   β”œβ”€β”€ Tabs.tsx
β”‚   β”‚   β”œβ”€β”€ README.md            # Component documentation
β”‚   β”‚   └── ... (30+ components)
β”‚   β”œβ”€β”€ analytics.tsx            # Analytics (dynamically loaded)
β”‚   β”œβ”€β”€ BackToTop.tsx            # Floating back-to-top button
β”‚   β”œβ”€β”€ Code.tsx                 # Prism syntax-highlighted code blocks
β”‚   β”œβ”€β”€ InlineCode.tsx           # Click-to-copy inline code
β”‚   β”œβ”€β”€ KeyboardShortcutsHelp.tsx # Keyboard shortcuts dialog ("?" key)
β”‚   β”œβ”€β”€ RelatedArticles.tsx      # Tag-based related content
β”‚   β”œβ”€β”€ ShareButtons.tsx         # Social sharing buttons
β”‚   β”œβ”€β”€ TableOfContents.tsx      # Responsive TOC with active tracking
β”‚   β”œβ”€β”€ ThemeProvider.tsx        # next-themes provider wrapper
β”‚   β”œβ”€β”€ ThemeToggle.tsx          # Dark/light mode toggle
β”‚   β”œβ”€β”€ header.tsx               # Site header
β”‚   └── footer.tsx               # Site footer (dynamically loaded)
β”œβ”€β”€ config/                       # Configuration files
β”‚   β”œβ”€β”€ config.base.ts           # Base configuration (template defaults)
β”‚   β”œβ”€β”€ config.private.ts        # Production overrides (committed)
β”‚   β”œβ”€β”€ config.local.example.ts  # Example dev overrides (copy to config.local.ts)
β”‚   └── site.ts                  # Aggregator that merges all configs
β”œβ”€β”€ content/                      # MDX documentation files
β”‚   └── component-examples.mdx   # Component showcase (reference)
β”œβ”€β”€ hooks/                        # Custom React hooks
β”‚   β”œβ”€β”€ use-mobile.ts
β”‚   └── use-toast.ts
β”œβ”€β”€ lib/                          # Utility functions
β”‚   β”œβ”€β”€ mdx-utils.ts             # MDX parsing utilities
β”‚   β”œβ”€β”€ extract-headings.ts      # TOC extraction
β”‚   └── utils.ts                 # General utilities
β”œβ”€β”€ public/                       # Static assets
β”‚   β”œβ”€β”€ robots.txt
β”‚   └── assets/
β”œβ”€β”€ types/                        # TypeScript definitions
β”œβ”€β”€ next.config.mjs              # Next.js configuration
β”œβ”€β”€ tailwind.config.ts           # Tailwind configuration
β”œβ”€β”€ tsconfig.json                # TypeScript configuration
└── package.json                 # Dependencies & scripts

πŸ›  Tech Stack

Technology Purpose
Next.js 16 React framework with App Router
React 19 UI library
TypeScript Type safety
Tailwind CSS 4 Utility-first CSS
MDX Markdown + JSX
Radix UI Accessible component primitives
Lucide Icon library
Prism Syntax highlighting
gray-matter Frontmatter parsing
next-themes Dark mode / theme management

🎨 Customization

Quick Configuration ⚑ (Recommended)

The easiest way to customize your site is using the three-file config system:

πŸ‘‰ Edit config/config.private.ts - Production settings (domain, analytics, social links).

πŸ‘‰ Copy & edit config/config.local.ts (optional) - Dev-only overrides (copy from config.local.example.ts).

See the Configuring Your Site section above for all options.

Advanced Customization

  • Global styles: app/globals.css
  • Tailwind config: tailwind.config.ts
  • Code highlighting: app/code-highlight.css

Components

Add custom components in components/ and import them in MDX files.

Performance Optimization

The application implements performance best practices:

  • Dynamic Imports - Non-critical components (Footer, Analytics) are dynamically imported in app/layout.tsx
  • Server Components - Layout and pages use Next.js Server Components by default for better performance
  • Lazy Loading - Components are loaded only when needed, reducing initial bundle size

Example - Dynamic Import Pattern:

import dynamic from "next/dynamic";

const Footer = dynamic(() => import("@/components/footer"), {
  ssr: true,
});

Importing Components

Always use the correct import path with PascalCase names:

// βœ… Correct
import { Button } from "@/components/ui/Button";
import { Card, CardHeader, CardContent } from "@/components/ui/Card";

// ❌ Incorrect (old naming convention)
import { Button } from "@/components/ui/button";

Adding New Components

When creating new UI components:

  1. Place them in components/ui/ with PascalCase filenames
  2. Use Radix UI as the foundation for accessible components
  3. Style with Tailwind CSS
  4. Export from the component file and import with PascalCase naming
  5. Consider organizing in subfolders (buttons/, forms/, modals/) based on functionality

Example Component Structure:

// components/ui/Button.tsx
import * as React from "react";
import { cn } from "@/lib/utils";

interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: "primary" | "secondary";
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
  ({ className, variant = "primary", ...props }, ref) => (
    <button
      ref={ref}
      className={cn(
        "px-4 py-2 rounded font-medium transition-colors",
        variant === "primary" && "bg-blue-600 text-white hover:bg-blue-700",
        variant === "secondary" &&
          "bg-gray-200 text-gray-800 hover:bg-gray-300",
        className,
      )}
      {...props}
    />
  ),
);

Button.displayName = "Button";
export { Button };

Content Guidelines

  • Store all documentation in the content/ folder
  • Organize by topic in subfolders (e.g., content/guides/, content/api/)
  • Use frontmatter for metadata (title, description, tags)
  • Keep MDX files focused and modular

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments


Made with ❀️ by kolasokol

Documentation β€’ GitHub β€’ Issues

About

A modern, high-performance documentation platform built with Next.js 16 and MDX

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages