https://github.com/redpanda-data/docs-ui
UI project for the Redpanda documentation site.
https://github.com/redpanda-data/docs-ui
Last synced: about 1 month ago
JSON representation
UI project for the Redpanda documentation site.
- Host: GitHub
- URL: https://github.com/redpanda-data/docs-ui
- Owner: redpanda-data
- License: mpl-2.0
- Created: 2023-03-06T09:12:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-05-12T10:26:50.000Z (about 2 months ago)
- Last Synced: 2026-05-12T12:32:39.756Z (about 2 months ago)
- Language: CSS
- Homepage:
- Size: 32.9 MB
- Stars: 4
- Watchers: 11
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Redpanda Documentation UI
:url-docs: https://docs.redpanda.com
:url-org: https://github.com/redpanda-data
:ui-project: docs-ui
:url-ui: {url-org}/{ui-project}
:url-extensions: {url-org}/docs-extensions-and-macros
:url-site: {url-org}/docs-site
:url-redpanda: https://redpanda.com
:url-antora: https://antora.org/
:hide-uri-scheme:
:url-contributing: {url-site}/blob/main/meta-docs/CONTRIBUTING.adoc
:url-netlify: https://netlify.com
:url-netlify-docs: https://docs.netlify.com
:url-antora-docs: https://docs.antora.org
:url-redoc: https://github.com/Redocly/redoc
:url-nodejs: https://nodejs.org/en/download
:url-git: https://git-scm.com/downloads
:idprefix:
:idseparator: -
:experimental:
ifdef::env-github[]
:important-caption: :exclamation:
:note-caption: :paperclip:
endif::[]
:toc:
:toc-title: Contents
toc::[]
This project is used to develop and distribute the UI for the {url-site}[Redpanda documentation site].
The UI bundle this project produces is intended to be used with {url-antora}[Antora].
The UI bundle contains the HTML templates, CSS, JavaScript, fonts, and site-wide images.
The rest of the material for the documentation site comes from the {url-site}[playbook repository] and content repositories.
== Usage
To use this UI with Antora, add the following configuration to your playbook file:
[source,yaml,subs=attributes+]
----
ui:
bundle:
url: {url-ui}/releases/latest/download/ui-bundle.zip
----
== Development Quickstart
In this section, you learn how to set up the UI project, preview it locally, and bundle it for use with Antora.
=== Prerequisites
To preview and bundle the UI, you need the following software on your computer:
==== git
Make sure you have git installed.
[,bash]
----
git --version
----
If not, {url-git}[download and install] the git package for your system.
==== Node.js
You must have {url-nodejs}[Node.js] 18 or higher installed on your machine.
[,bash]
----
node --version
----
If this command fails, you don't have Node.js installed.
==== Gulp CLI
You'll need the Gulp command-line interface (CLI) to run the build.
This package provides the `gulp` command which, in turn, executes the version of Gulp declared by the project.
You should install the Gulp CLI globally (which resolves to a location in your user directory if you're using nvm) using the following command:
[,bash]
----
npm install -g gulp-cli
----
Verify the Gulp CLI is installed and on your PATH by running:
[,bash]
----
gulp -v
----
Now that you have the prerequisites installed, you can fetch and build the UI project.
==== Golang
Part of the bundle process uses Golang (Go) to build a WebAssembly (`.wasm`) file. As a result, you need Go installed on your machine.
Verify that Go is installed:
[,bash]
----
go version
----
If Go is not installed, https://go.dev/doc/install[download and install it].
NOTE: For Netlify previews, we set the `GO_VERSION` https://docs.netlify.com/configure-builds/manage-dependencies/#go[environment variable] to 1.23.4 to match the version in the `go.mod` file.
=== Clone and Initialize the UI Project
Clone the UI project using git:
[,bash,subs=attributes+]
----
git clone {url-ui}
cd {ui-project}
----
The example above clones the Redpanda docs UI project and then switches to the project directory on your filesystem.
Stay in this project directory when executing all subsequent commands.
Use npm to install the project's dependencies inside the project.
In your terminal, execute the following command:
[,bash]
----
npm install
----
This command installs the dependencies listed in `package.json` into the `node_modules/` directory inside the project.
This directory does not get included in the UI bundle and should _not_ be committed to the source control repository.
=== Preview the UI
The UI project is configured to preview offline.
The files in the `preview-src/` directory provide the sample content that allows you to see the UI in action.
In this directory, you'll primarily find pages written in AsciiDoc.
These pages provide a representative sample and kitchen sink of content from the real site.
To build the UI and preview it in a local web server, run the `preview` command:
[,bash]
----
gulp preview
----
You'll see a URL listed in the output of this command:
....
[17:32:55] Starting 'preview:serve'...
[17:32:55] Starting server...
[17:32:55] Server started http://localhost:5252 and http://192.168.1.3:5252
[17:32:55] Running server
....
Navigate to this URL to preview the site locally.
While this command is running, any changes you make to the source files will be instantly reflected in the browser.
This works by monitoring the project for changes, running the `build` task if a change is detected, and sending the updates to the browser.
Press kbd:[Ctrl+C] to stop the preview server and end the continuous build.
==== Preview Online
You can share a preview of the UI online by submitting a pull request to GitHub.
The repository is configured to create a deploy preview on Netlify for every pull request.
=== Package for Use with Antora
If you need to package the UI so you can use it to generate the documentation site locally, run the following command:
[,bash]
----
gulp bundle
----
If any errors are reported by lint, you'll need to fix them.
When the command completes successfully, the UI bundle will be available at `build/ui-bundle.zip`.
You can point Antora at this bundle using the `--ui-bundle-url` command-line option or in the `ui.bundle.url` property of the playbook file.
== Control the Visual Appearance of Pages
To control the visual appearance of pages, the UI bundle provides a CSS stylesheet (for changing the CSS style rules) and any number of layouts in the form of Handlebars templates (for changing the HTML).
Although most styles are used on all pages, it's possible to configure styles to target certain pages based on the layout.
This section will introduce these various options and explain how they work.
=== UI Layouts
The most drastic way to change the appearance of the page is to change the HTML.
The HTML is controlled by layouts, which are Handlebars templates located in [.path]_src/layouts_.
A layout typically includes partials, located in [.path]_src/partials_, which are reusable template fragments.
Partials may, in turn, include other partials.
This project currently has five layouts:
* default.hbs
* 404.hbs
* home.hbs
* index.hbs
* search.hbs
If a page doesn't specify a layout, the `default.hbs` layout is used.
To specify a layout, the page file must declare the `page-layout` document attribute in the AsciiDoc header.
The value of that attribute should match the stem of the layout file (the filename minus the file extension, such as `home`).
For example, the home page declares the following document attribute in the AsciiDoc header:
[source,asciidoc]
----
= Redpanda Documentation
:page-layout: home
----
In this case, Antora will select the `home.hbs` layout for this page instead of `default.hbs`.
Using a dedicated layout affords a lot of control over what gets displayed on this page.
Every layout has access to the same UI model.
The home page likely requires additional styles that are only relevant to that page.
You can organize these styles inside a namespace by adding a dedicated class to the `` tag.
In fact, that's what the `home.hbs` layout currently does.
[source,html]
----
...
----
You can now define styles that are scoped to that page as follows:
[source,css]
----
.home h1,
.home h2,
.home h3 {
line-height: 1.2;
margin: 0;
}
----
To make these styles easier to find and manage, they should be organized in a dedicated file `src/css/home.css` and included in the master `src/css/site.css` file, which is how this project is currently configured.
When you run the preview, you can see the home page by visiting the URL \http://localhost:5002/home.html.
=== Content Preview
You can create an arbitrary number of pages for the preview site.
To make a page, create a new AsciiDoc file inside the `preview-src` directory.
You can then access the page in the preview site using the URL pattern \http://localhost:5252/.html, where `` is the stem of the source file (the filename minus the file extension).
These preview pages serve the purpose of testing the page layout and content styling.
Each page may declare a layout, role, or both.
The only caveat is that, at the moment, every page provides the same UI model (with a few exceptions).
The model is defined in `preview-src/ui-model.yml` file.
The exceptions include the layout, role, title, contents, and, in the case of home.adoc, the component, which get updated dynamically by the build.
For information about what goes in the UI model, refer the https://docs.antora.org/antora-ui-default/templates/[Handlebars templates page] in the Antora documentation.
== Integrations
=== Algolia Search
This UI provides integration with Algolia search.
The Algolia client is configured in the files `src/partials/algolia-script.hbs` and `src/layouts/search.hbs`.
You can test the search directly from the preview site by setting the following environment variables in your shell:
* `ALGOLIA_APP_ID` - the application ID that hosts the search index
* `ALGOLIA_API_KEY` - your API key for Algolia
* `ALGOLIA_INDEX_NAME` - the name of the index
You can point to any index that is publicly accessible.
== Release the UI Bundle
Once you're satisfied with the changes you've made to the UI and would like to make those changes available to Antora, you'll need to publish the UI as a bundle by making a release.
This project provides a GitHub Action that fully automates the release.
Whenever you push a new tag to this repository, the GitHub Action will generate a new release and bundle the UI before publishing the bundle to the releases section of the repository on GitHub.
The bundle can then be downloaded using a unique URL, accessible from the release page.
You can see a list of all past releases on the {url-ui}/releases[releases page].
== Troubleshooting
If you’re trying to bundle the UI on Windows, Visual Studio Code can output this error message: `Cannot be loaded because running scripts is disabled on this system`. To fix this problem, follow the steps in https://stackoverflow.com/a/67420296[this post].
== Copyright and License
=== Software
The software in this repository (build scripts, JavaScript files, Handlebars templates, foundation CSS, utility icons, etc) is part of the {url-antora}[Antora project].
As such, the use of the software is granted under the terms of the https://www.mozilla.org/en-US/MPL/2.0/[Mozilla Public License Version 2.0] (MPL-2.0).
=== Branding and Design
Copyright (C) {url-redpanda}[Redpanda] 2024.
All rights reserved.