Skip to main content

static-assets-hook

TL;DR

Registers a directory with media files.

After the hook registration, you can use files from the directory in the *.md[x] files and the React pages by their name.

Integration:

1. Add dependency

yarn add -WD "@docusaurus-tde/static-assets-hook"

2. Create directory.

Create a directory <root>/docs/assets on the same level as docusaurus-tde.config.js.

3. Add files.

Create any file in the assets directory (for clarity, you can use an image).

4. Connect the hook

docusaurus-tde.config.js
const path = require('path')

module.exports = {
hooks: [
['@docusaurus-tde/static-assets-hook', { staticDirectories: [path.join(__dirname, 'assets')] }],
]
}

5. Use files.

  • Connect the file in the documentation using his name.
  • Run the documentation server

For example, if you added an image to the assets directory with the name logo.png, you can display it:

![logo](/logo.png)

Hook configuration:

type staticAssetsHookProps = {
staticDirectories: string[];
}