Assets
Sometimes you want to link to static assets directly from Markdown files, and it is convenient to co-locate the asset next to the markdown file using it.
We have setup Webpack loaders to handle most common file types, so that when you import a file, you get its url, and the asset is automatically copied to the output folder.
Let's imagine the following file structure:
#
ImagesYou can use images in Markdown, or by requiring them and using a JSX image tag:
The ES imports syntax also works:
This results in displaying the image:
note
If you are using @docusaurus/plugin-ideal-image, you need to use the dedicated image component, as documented.
#
FilesIn the same way, you can link to existing assets by requiring them and using the returned url in videos, links etc.
Download this PDF using Markdown
#
Inline SVGsDocusaurus supports inlining SVGs out of the box.
This can be useful, if you want to alter the part of the SVG image via CSS. For example, you can change one of the SVG colors based on the current theme.
#
Themed ImagesDocusaurus supports themed images: the ThemedImage
component (included in the classic/bootstrap themes) allows you to switch the image source based on the current theme.