Wikity is a tool that allows you to use Wikitext (used by Wikipedia, Fandom, etc) as a templating language to create HTML pages.
This package comes with built-in support for compilation using Eleventy.
See the example folder for a template on making your own wiki site!
Wikity is available on npm. Install locally to use in a Node package or install globally for use from the command-line.
| Local install | Global install |
|---|---|
npm install wikity |
npm install -g wikity |
-
wikity.compile(folder?: string, options?: object): void- Compile all Wikitext (
.wiki) files from an input folder (defaults to the current directory,.) into HTML.
- Compile all Wikitext (
-
wikity.parse(input: string, options?: object): string- Parse raw wikitext input into HTML.
-
Options:
eleventy: boolean = false- Whether front matter will be added to the outputted HTML for Eleventy to read (default:
false). (This parameter must be set totrueif you want to use this with Eleventy.)
- Whether front matter will be added to the outputted HTML for Eleventy to read (default:
outputFolder: string- Used only with
compile(). - Where outputted HTML files shall be placed.
- Default:
'wikity-out'.
- Used only with
templatesFolder: string- What folder to place templates in.
- Default:
'templates'.
imagesFolder: string- What folder to place images in.
- Default:
'images'.
defaultStyles: boolean- Used only with
compile(). - Whether to use default wiki styling.
- Default: to
truewhen called fromcompile()andfalsewhen called fromparse().
- Used only with
customStyles: string- Used only with
compile(). - Custom CSS styles to add to the wiki pages.
- Default: empty (
'').
- Used only with
const wikity = require('wikity');
// compile all .wiki files inside this directory
wikity.compile();
// parse wikitext from an input string
let html = wikity.parse(`'''bold''' [[link|text]]`); // <b>bold</b> <a href="link"...>text</a>Use Wikity along with Eleventy to have all your wiki files compiled during the build process:
// .eleventy.js (eleventy's configuration file)
const wikity = require('wikity');
module.exports = function (eleventyConfig) {
const rootFolder = 'src';
const templatesFolder = 'templates', imagesFolder = 'images'; // defaults; relative to root folder
const outputFolder = 'wikity-out'; // default
const wikityOptions = { eleventy: true, templatesFolder, imagesFolder, outputFolder };
const wikityPlugin = () => wikity.compile(rootFolder, wikityOptions);
eleventyConfig.addPlugin(wikityPlugin);
eleventyConfig.addPassthroughCopy({ 'src/images': 'wiki/' + imagesFolder }); // Eleventy does not pass through images by default
}The above will use the following file structure (with some example wiki files given):
src/templates/: Directory for wiki templates (called like{{this}})images/: Directory to place images (called like[[File:this]])Index.wiki: Example fileOther_Page.wiki: Example other file
wikity-out/: File templates compiled from the.wikifiles (add this to.gitignore)wiki/: Output HTML files compiled fromwikity-out/(add this to.gitignore)
(View the above starting at the URL path /wiki/ when ran in an HTTP server.)
$ wikity help
Display a help message
$ wikity compile [<folder>] [-o <folder>] [-t <folder>] [-e] [-d]
Compile Wikity with various options
$ wikity parse <input>
Parse raw input into HTML
$ wikity version
Display the latest version of WikityUse Wikitext (file extension .wiki) to create your pages.
Any wiki templates (called using {{template name}}) must be inside the templates/ folder by default.
Any files must be inside the images/ folder by default.
Your wikitext (*.wiki) files go in the root directory by default.

