useAsset
is a core functionality automatically makes assets from the CMS available to the front-end.
The asset module exports different functions of which only one has to be used: useGlossary
. The other functions are for internal use by the architecture and will not be documented.
Our websites run on many environments that might also change their URLs at some point, so for that reason we decided to dynamically add an environment url to our assets.
Let's say you get a dpdk-architecture.pdf
from the API and want to link to it, you simply do:
// assetUrl in config for example: https://dpdk.com
const documentPath = '/cms/assets/dpdk-architecture.pdf'
useAsset(documentPath); // https://dpdk.com/cms/assets/dpdk-architecture.pdf
The environment URL will be set in the core and comes from configuration, see this page for more information.
Last modified | Wednesday, February 3, 2021, 10:17:16 AM UTC |
Last author | Colin van Eenige |
Commit ID | a5fc248 |