Skip to content

Update Landing Page (index.md) for Documentation

pre-commit hook id: docs-landing-page

Run this hook to update the landing page (root index.md file) for your documentation.

The hook copies the root README.md file into the root of your documentation folder, renaming it to index.md and implementing any replacements specified.

The hook will run when the root README.md file is changed in the repository.

The hook expects the documentation to be a framework that can build markdown files for deploying a documentation site.

Expectations

It is required that the root README.md exists and the documentation's landing page is named index.md and can be found in the root of the documentation folder.

Options

Any of these options can be given through the args key when defining the hook.

Name Description Required Type Default
--docs-folder The folder name for the documentation root folder. No string docs
--replacement A replacement (mapping) to be performed on README.md when creating the documentation's landing page (index.md). This list always includes replacing '--docs-folder/' with an empty string, in order to correct relative links. By default the value (LICENSE),(LICENSE.md) is set, but this will be overwritten if args is set.

This input option can be supplied multiple times.
No string (LICENSE),(LICENSE.md)
--replacement-separator String to separate a replacement's 'old' to 'new' parts. Defaults to a comma (,). No string ,

Usage example

The following is an example of how an addition of the Update Landing Page (index.md) for Documentation hook into a .pre-commit-config.yaml file may look. It is meant to be complete as is.

repos:
  - repo: https://github.com/SINTEF/ci-cd
    rev: v2.8.0
    hooks:
    - id: docs-landing-page
      args:
      # Replace `(LICENSE)` with `(LICENSE.md)` (i.e., don't overwrite the default)
      - '--replacement'
      - '(LICENSE);(LICENSE.md)'
      # Replace `(tools/` with `(`
      - '--replacement'
      - '(tools/;('
      - '--replacement-separator'
      - ';'