Sign inSign up

weaponsforge/fumadocs-routes

By weaponsforge

•Updated 10 days ago

Generates Next.js/Fumadocs docs content routes into a custom JSON for proxy.ts middleware redirects

Image
Integration & delivery
Developer tools
Web servers
0

124

weaponsforge/fumadocs-routes repository overview

⁠fumadocs-routes

Generates docs-routes.json containing a list of root docs sections + labels, private sections, public exceptions and private pages from the private frontmatter or meta flags in Fumadocs content/docs/.

Its output is a lightweight JSON file, intended for a Fumadocs project's proxy.ts to import and use for auth-gated server-side redirects and session checks.

Fumadocs content folders set the flag in meta.json and pages set it in their frontmatter.

GitHub Repository
https://github.com/weaponsforge/fumadocs-routes⁠

⁠Requirements

  1. Fumadocs⁠ documentation project (tested for Next.js - App Router. Other options/variations are untested)

  2. Fumadocs source.config.ts extended to hold the private field in its meta.json and frontmatter (pages).

    👉 Click to view custom config

    source.config.ts

    import { metaSchema, pageSchema } from 'fumadocs-core/source/schema'
    import { defineConfig, defineDocs } from 'fumadocs-mdx/config'
    import { z } from 'zod'
    
    export const docs = defineDocs({
      dir: 'content/docs',
      docs: {
        schema: pageSchema.extend({
          private: z.boolean().default(false),
        }),
      },
      meta: {
        schema: metaSchema.extend({
          private: z.boolean().default(false),
        }),
      },
    })
    

⁠Usage

  1. Pull the "latest" production image.
    docker pull weaponsforge/fumadocs-routes

  2. Navigate to a Next.js (App Router) - Fumadocs project using the command line.

  3. Take note of the "content/docs/" folder location in the Fumadocs project. Fumadocs initializes it by default in /<project-root>/content/docs. Example:

    fumadocs-project/
    ├── content/                # MDX docs content
    |   └── docs/
    |       ├── characters/
    |       |   ├── meta.json
    |       |   ├── index.mdx
    |       |   ├── knight.mdx
    |       |   ├── wizard.mdx
    |       |   ├── elf.mdx
    |       └── information/
    |           ├── meta.json
    |           ├── index.mdx
    |           └── training.mdx
    ├── package.json
    ├── ...
    
  4. Mark private folders and pages.

    • Add "private": true in the meta.json of main folders (sections) or nested sub-folders that you'd like to keep private.

    • Add private: true in the frontmatter of *.mdx files for specific pages that you'd like to keep private.

    INFO: Marking them private does not automatically make them private in Fumadocs. You'd need to set its proxy.ts for auth gates (eg., configure Google OAuth2 sign-in, session checks) and server-side redirects using the routes list output in step #5.

  5. Run to generate docs-routes.json

    eg., in PowerShell (within a Fumadocs project root folder):

    docker run --rm -v ${pwd}:/opt/app weaponsforge/fumadocs-routes
    

⁠CLI Flags Guide

OptionDescription
--docs, -dFumadocs docs folder path.
Default: <root>/content/docs
--output,
-o
Folder to write docs-routes.json into. A file path is rejected,
the file is always named docs-routes.json. Missing folders are created.
Default: <root>
--strictA top-level folder without meta.json is an error instead of a warning. See Validation⁠.
Default: off
  • <root> is the nearest folder with a package.json, searched from the working directory upwards.
  • Relative paths resolve from the working directory.

⁠Output

Sample docs-routes.json

{
  "sections": ["characters", "secrets", "stats-calculator", "weapons"],
  "section_labels": {
    "characters": "MU Online characters",
    "secrets": "MU Online secrets",
    "stats-calculator": "Character Stats Calculator",
    "weapons": "MU Online weapons"
  },
  "private_sections": ["secrets", "stats-calculator"],
  "public_exceptions": ["secrets", "secrets/skill-tips"],
  "private_pages": ["characters/elf"]
}
KeyContents
sectionsFolders served at /docs/<folder> whose meta.json has root: true: the non-group children of content/docs, plus folders inside top-level groups (content/docs/(extra)/items → items). Nested root: true folders such as characters/classes are not sections, because sections only key on the first URL segment.
section_labelsOne label per section, used for llms.txt headings. The first non-empty value of: the meta.json description, the index.mdx description, the slug.
private_sectionsURL prefixes of the topmost private, non-group folders (can be nested, e.g. characters/wizards). Every URL under a prefix is gated, including URLs that don't exist.
public_exceptionsExact slugs of public pages under a private prefix.
private_pagesExact slugs of private pages not covered by a prefix: a private page in a public section, or the pages of a private (group) folder.

Slugs follow Fumadocs URLs: (group) segments, the .mdx/.md extension and a trailing index are dropped.

Tag summary

Content type

Image

Digest

sha256:6aea7efb1…

Size

59.3 MB

Last updated

10 days ago

docker pull weaponsforge/fumadocs-routes