Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wiki.js-cli

A command-line interface for managing Wiki.js content via GraphQL API.

Features

  • List all pages
  • Display page tree structure
  • Search pages by keyword
  • Fetch a single page by ID or path
  • Create new pages from Markdown files

Prerequisites

  • Go 1.21+
  • A running Wiki.js instance with GraphQL API enabled
  • An API token with sufficient permissions

Installation

go build -o wiki.js-cli .

Or run directly:

go run main.go <command> [flags]

Configuration

Create a .env file with your Wiki.js credentials:

GRAPHQL_ENDPOINT=http://your-wiki-js-host/graphql
TOKEN=your-api-token-here

Load the env file with the --env flag:

./wiki.js-cli --env .env pages

Usage

Global Flags

Flag Description Default
--json Output in JSON format false
--env Path to .env file ""
--locale Locale for queries "zh"

Commands

List Pages

List all pages in the Wiki.js instance.

./wiki.js-cli --env .env pages
./wiki.js-cli --env .env --json pages

Show Page Tree

Display the hierarchical tree structure of pages.

./wiki.js-cli --env .env tree
./wiki.js-cli --env .env tree -p 0
./wiki.js-cli --env .env --json tree
Flag Description Default
-p, --parent Parent node ID 0

Search Pages

Search pages by keyword.

./wiki.js-cli --env .env search -k "hello"
./wiki.js-cli --env .env --json search -k "hello"
Flag Description Default
-k, --keyword Search keyword (required)

Fetch Single Page

Retrieve a single page by ID or path.

./wiki.js-cli --env .env page --id 1
./wiki.js-cli --env .env page --path "home"
./wiki.js-cli --env .env --json page --id 1
Flag Description Default
--id Page ID 0
--path Page path ""

Create Page

Create a new page from a Markdown file.

./wiki.js-cli --env .env create --title "My Page" --path "docs/my-page" --locale en --file ./content.md
./wiki.js-cli --env .env create --title "My Page" --path "docs/my-page" --locale en --file ./content.md --description "A test page"
Flag Description Required Default
--title Page title Yes
--path Page URL path Yes
--locale Page locale Yes
--file Content file path Yes
--description Page description No ""
--publish Publish immediately No true
--private Make page private No false

Project Structure

wiki.js-cli/
├── cmd/                    # CLI commands (Cobra)
│   ├── root.go             # Root command & global flags
│   ├── pages.go            # List all pages
│   ├── page.go             # Fetch single page
│   ├── tree.go             # Display page tree
│   ├── search.go           # Search pages
│   └── create.go           # Create a new page
├── internal/
│   └── wiki.js/
│       └── wikijs.go       # Wiki.js GraphQL client
├── main.go                 # Entry point
├── .env                    # Environment configuration
└── go.mod                  # Go module definition

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages