Dynamic Content

Doctave supports dynamic content via user preferences. This means you can customize what content your readers will see based on their preferences.

This can be useful if your product has multiple tiers, and you want to hide specific features based on the user's selected tier.

The user is able to select their preference from a dropdown in the navigation, and you can customize both the navigation and Markdown content based on their choice.

Example of a user preference dropdown showing different plans the user can select from

Customizing content in Markdown

Your Markdown content can be customized based on user preferences.

For example, if you have defined a user preference called plan, like above, you can access the current value:

{% if DOCTAVE.user_preferences.plan == "Starter" %}
You are on the starter plan
{% endif %}

Or, you can render the current value:

{{ DOCTAVE.user_preferences.plan }}

Customizing navigation

Sections in the navigation can be shown based on a condition, using the show_if property.

- heading: API Reference
  show_if:
    user_preferences:
      plan:
        one_of:
          - Growth
          - Enterprise

In the above example, we're telling Doctave to only show the API Reference section if the user has selected as their plan either Growth or Enterprise. See more in the User Preferences section.

Conditionals are based on matchers which you can use to determine when a section or link should be shown.

Equals

equals is the simplest matcher. It checks that the given plan is an exact match.

show_if:
  user_preferences:
    plan:
      equals: Enterprise

One Of

one_of matcher expects as an argument a list of values to match against.

show_if:
  user_preferences:
    plan:
      one_of:
        - Growth
        - Enterprise

Was this page helpful?