Keystatic Documentation

repository·main·Indexed 24 days ago

https://github.com/thinkmill/keystatic

A file-based CMS with a TypeScript API that allows developers to manage content using Markdown and YAML/JSON without a database. Designed for integration with Next.js, Remix, and Astro, Keystatic connects directly to GitHub. The documentation covers project bootstrapping via @keystatic/create, configuration using the config() function, and the KeystarUI open-source component library.

Tokens
32.4K
Snippets
52
Records
173
Agent score
81%

What's inside Keystatic

  1. Overview of Keystatic Localization

    main
    Keystatic Localization is an application designed to provide a user interface for managing localization (l10n) data for Keystatic projects. It allows non-technical contributors or those preferring a CMS-like experience to manage content and data that is otherwise stored in code-based formats like Markdown, JSON, or YAML.
  2. Overview of Keystar UI Primitives

    main

    Keystar UI Primitives provides the foundational typography, sizing, and color tokens for the Keystar design system.

    Note for Developers: The system is currently in development. It is acceptable to copy/paste tokens and manually adjust them as needed while the automation and validation workflows (such as Zod validation and Storybook previews) are being implemented.

  3. What is Keystatic?

    main
    Keystatic is a first-class CMS experience designed for modern front-end frameworks like Next.js, Remix, and Astro. It provides a TypeScript API and uses Markdown and YAML/JSON as data formats without requiring a database. It connects directly to GitHub and is designed to work with your existing source code without modifying it.
  4. Create custom content components

    main

    You can extend the Keystatic editor by defining custom components for document fields or specialized content types like MDX/Markdoc. Components can be:

    • block: A structural component that wraps content.
    • inline: A component that lives within a line of text.
    • mark: A component used for text highlighting/styling.

    Components use a schema to define their own editable properties and a preview function to render how the component looks in the editor.

    const components = {
      Highlight: mark({
        label: 'Highlight',
        icon: highlighterIcon,
        schema: {
          variant: fields.select({
            label: 'Variant',
            options: [
              { label: 'Fluro', value: 'fluro' },
              { label: 'Minimal', value: 'minimal' },
              { label: 'Brutalist', value: 'brutalist' },
            ],
            defaultValue: 'fluro',
          }),
        },
      }),
    };
  5. Core design principles of KeystarUI

    main

    KeystarUI components are built around four core values:

    • Accessible: Components are fully compatible with screen readers and support keyboard navigation.
    • Responsive: Components support mouse, touch, and keyboard interactions and use responsive design to work across all devices.
    • Adaptive: Components support both light and dark color schemes and can automatically adjust to the user's system settings.
    • Inclusive: Components are engineered for a global audience, supporting features like right-to-left (RTL) language display and localized date and number formatting.
  6. Understand Keystatic project templates

    main

    Keystatic provides two types of templates through the CLI:

    1. Simple templates: Basic implementations with minimal dependencies, stored within the main monorepo.
    2. Complex templates: Advanced examples stored in separate repositories to manage dependencies and assets efficiently.

    All templates are published to npm and are downloaded by the CLI during the setup process. The CLI ensures that the template major version matches the CLI major version to prevent using out-of-date or incompatible cached versions.

  7. Understand the Keystar design system token structure

    main

    The design system is organized into collections that support multiple modes (e.g., light and dark themes).

    Current Collections

    • color: Includes scales, aliases, backgrounds, foregrounds, icons, and shadows. Supports light and dark modes.
    • size: Includes scales, borders, containers, dialogs, elements, icons, and radius/spacing.

    Token Composition

    Instead of using arbitrary t-shirt sizes for typography, the system aims to use semantic names (e.g., caption) that compose multiple properties into a single variant:

    • color
    • fontFamily
    • fontSize
    • fontWeight
    • lineHeight
    • textTransform
  8. Keystatic system requirements

    main

    To run Keystatic or its development projects, ensure your environment meets the following requirements:

    • Node.js: v18 or higher
    • Package Manager: pnpm

    If you encounter issues with pnpm, it is recommended to use corepack. You can enable it by running:

    corepack enable pnpm