Source code - Fluid Topics - Latest

Fluid Topics Designer Guide

Category
Reference Guides
Audience
public
Version
Latest

The following example relies on:

To add the same Custom component:

  1. Open the Topic templates designer, and open a page.
  2. Add a Conditional visibility component.
  3. 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:isUnstructured
    Metadata value false

    This rule hides the component for content for which a Markdown version is not available.

  4. Add a Custom component inside the Conditional visibility component, and open it.

  5. 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.

  6. In the CSS panel, copy and paste the following:

    ft-button {
      --ft-button-color: #282832;
      --ft-button-icon-size: 28px;
    }
    
  7. 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 ftCallingApp header. To exclude these API calls from billing, set the ftCallingApp value to a name starting with custom-component.

  8. Save the component.

  9. Save and publish the page.

This procedure creates the following element:

Below is a preview of the a topic displayed in Markdown.

An animation of a reader page displaying the Fluid Topics quick start guide. The display topic in Markdown button is highlighted, then a user selects the button. A new window opens displaying the topic in Markdown format.