The following example relies on:
- The Get a topic's content web service
- The Map variable (contains information about the current open map).
- The Topic variable (contains information about the current open topic).
To add the same Custom component:
- Open the Topic templates designer, and open a page.
- Add a Conditional visibility component.
-
In the component's Settings, add the following rule:
Field Value Apply when matching At least one rule Rule condition Document metadata Operator Contain Metadata key ft:isUnstructuredMetadata value falseThis rule hides the component for content for which a Markdown version is not available.
-
Add a Custom component inside the Conditional visibility component, and open it.
-
In the HTML panel, copy and paste the following:
<ft-button dense icon="FILE_CODE" variant="fluid-topics" label="See topic's Markdown content" tooltipposition="right"></ft-button>The icon is the following:
See Fluid Topics icons for more options.
-
In the CSS panel, copy and paste the following:
ft-button { --ft-button-color: #282832; --ft-button-icon-size: 28px; } -
In the JS panel, copy and paste the following:
async function displayTopicMarkdown() { try { FTAPI = await new window.fluidtopics.FluidTopicsApi(); FTAPI["ftCallingApp"] = "custom-component-topic-markdown-source"; const url = `/api/khub/maps/${map.id}/topics/${topic.contentId}/content?format=markdown`; window.open(url, "_blank"); } catch (error) { console.error("Error opening URL:", error); } } const button = document.querySelector("ft-button"); if (button) { button.addEventListener("click", displayTopicMarkdown); }Custom components that call the Fluid Topics API must include an
ftCallingAppheader. To exclude these API calls from billing, set theftCallingAppvalue to a name starting withcustom-component. -
Save the component.
- Save and publish the page.
This procedure creates the following element:
Below is a preview of the a topic displayed in Markdown.