Code Blocks

The code blocks on the documentation site and the blog are powered by rehype-pretty-code. The syntax highlighting is done using shiki.

It has the following features:

  1. Beautiful code blocks with syntax highlighting.
  2. Support for VS Code themes.
  3. Works with hundreds of languages.
  4. Line and word highlighting.
  5. Support for line numbers.
  6. Show code block titles using meta strings.

Thanks to Shiki, highlighting is done at build time. No JavaScript is sent to the client for runtime highlighting.

Example

./app.config.ts
import { defineConfig } from '@tanstack/start/config'
import viteTsConfigPaths from 'vite-tsconfig-paths'
 
export default defineConfig({
  vite: {
    plugins: [
      // this is the plugin that enables path aliases
      viteTsConfigPaths({
        projects: ['./tsconfig.json'],
      }),
    ],
  },
})

Word highlight

const multiply = (a, b) => a * b

Diff

const add = (a, b) => a + b 
const sub = (a, b) => a - b 
console.log("hello")