From 6150162bbeed069e4fb6e7e0775ce26003e0fb50 Mon Sep 17 00:00:00 2001 From: chdeskur Date: Thu, 31 Jul 2025 21:09:47 -0400 Subject: [PATCH 1/3] global variable docs --- fern/products/docs/docs.yml | 3 + .../custom-components/global-variables.mdx | 79 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 fern/products/docs/pages/component-library/custom-components/global-variables.mdx diff --git a/fern/products/docs/docs.yml b/fern/products/docs/docs.yml index ce87fbb5c..81bf3e92e 100644 --- a/fern/products/docs/docs.yml +++ b/fern/products/docs/docs.yml @@ -79,6 +79,9 @@ navigation: path: ./pages/component-library/custom-components/reusable-markdown.mdx - page: Custom React Components path: ./pages/component-library/custom-components/custom-react-components.mdx + - page: Global Variables + hidden: true + path: ./pages/component-library/custom-components/global-variables.mdx - section: Customization collapsed: true contents: diff --git a/fern/products/docs/pages/component-library/custom-components/global-variables.mdx b/fern/products/docs/pages/component-library/custom-components/global-variables.mdx new file mode 100644 index 000000000..30123393b --- /dev/null +++ b/fern/products/docs/pages/component-library/custom-components/global-variables.mdx @@ -0,0 +1,79 @@ +--- +title: Global Variables +--- + + +Global variables are not yet available. Please contact support@buildwithfern.com if you have any feedback or questions. + + +Global variables allow you to maintain consistency across your documentation and make updates easier by centralizing commonly used values. You can define and use global variables in several places within Fern documentation. + +## Define global variables + +Define global variables in your `docs.yml` file: + +```yaml docs.yml +variables: + - name: "API_VERSION" + value: "v1" + - name: "API_URL" + value: "https://api.example.com" +``` + +## Use variables in content + +Reference variables throughout your MDX content using double angle brackets: + +### In Markdown + +````mdx use-api.mdx +Use the latest version of the API: <> + +```bash +curl -X GET <>/api/<>/users +``` +```` + +### In API references + +```yaml openapi.yml +paths: + /users: + get: + description: | + The API version is <> + responses: + '200': + description: "Success" + content: + application/json: + schema: +``` + +### In docs.yml configuration + +You can also use variables in your `docs.yml` configuration. + +```yaml docs.yml +variables: + - name: "ADMIN_ROLE_NAME" + value: "admin" +``` + +```yaml docs.yml +roles: + - everyone + - <> + +navigation: + - tab: Admin + layout: + - page: Admin Dashboard + path: pages/admin-dashboard.mdx + viewers: + - <> +``` + + +Fern will not render variables in your content if they are not defined in your `docs.yml` configuration. Instead, the variable will be rendered as a literal string. + \ No newline at end of file From 8673edf6d38374f9b9e1b03cead0000337323b61 Mon Sep 17 00:00:00 2001 From: chdeskur Date: Thu, 31 Jul 2025 21:30:37 -0400 Subject: [PATCH 2/3] update conditional content --- fern/products/docs/docs.yml | 4 +- .../conditional-rendering.mdx | 49 ++++++++++++ .../custom-components/global-variables.mdx | 79 ------------------- 3 files changed, 51 insertions(+), 81 deletions(-) create mode 100644 fern/products/docs/pages/component-library/custom-components/conditional-rendering.mdx delete mode 100644 fern/products/docs/pages/component-library/custom-components/global-variables.mdx diff --git a/fern/products/docs/docs.yml b/fern/products/docs/docs.yml index 81bf3e92e..56937f31d 100644 --- a/fern/products/docs/docs.yml +++ b/fern/products/docs/docs.yml @@ -79,9 +79,9 @@ navigation: path: ./pages/component-library/custom-components/reusable-markdown.mdx - page: Custom React Components path: ./pages/component-library/custom-components/custom-react-components.mdx - - page: Global Variables + - page: Conditionally Rendered Content hidden: true - path: ./pages/component-library/custom-components/global-variables.mdx + path: ./pages/component-library/custom-components/conditional-rendering.mdx - section: Customization collapsed: true contents: diff --git a/fern/products/docs/pages/component-library/custom-components/conditional-rendering.mdx b/fern/products/docs/pages/component-library/custom-components/conditional-rendering.mdx new file mode 100644 index 000000000..fd0f00c4e --- /dev/null +++ b/fern/products/docs/pages/component-library/custom-components/conditional-rendering.mdx @@ -0,0 +1,49 @@ +--- +title: Conditionally Rendered Content +--- + +You can conditionally render content based on the instance or version of the docs, in addition to the role of an authenticated user. + +## Conditionally render content + +### Between instances + +Define instances in your `docs.yml` file: + +```yaml docs.yml +instances: + - url: fern-dev.docs.buildwithfern.com + name: development + - url: fern-prod.docs.buildwithfern.com + name: production +``` + +```mdx conditional-rendering.mdx + + This is a beta feature. It should only be available when the docs have been generated with the `development` instance. + + + + This is a production feature. It should only be available when the docs have been generated with the `production` instance. + +``` + +### Between versions + +```mdx conditional-rendering.mdx + + This is an old feature. It should only be available when the user is on the `v1` version. + + + + This is a new feature. It should only be available when the user is on the `v2` version. + +``` + +### Based on the role of an authenticated user + +```mdx conditional-rendering.mdx + + This is an admin feature. It should only be available when the user is an admin. + +``` \ No newline at end of file diff --git a/fern/products/docs/pages/component-library/custom-components/global-variables.mdx b/fern/products/docs/pages/component-library/custom-components/global-variables.mdx deleted file mode 100644 index 30123393b..000000000 --- a/fern/products/docs/pages/component-library/custom-components/global-variables.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: Global Variables ---- - - -Global variables are not yet available. Please contact support@buildwithfern.com if you have any feedback or questions. - - -Global variables allow you to maintain consistency across your documentation and make updates easier by centralizing commonly used values. You can define and use global variables in several places within Fern documentation. - -## Define global variables - -Define global variables in your `docs.yml` file: - -```yaml docs.yml -variables: - - name: "API_VERSION" - value: "v1" - - name: "API_URL" - value: "https://api.example.com" -``` - -## Use variables in content - -Reference variables throughout your MDX content using double angle brackets: - -### In Markdown - -````mdx use-api.mdx -Use the latest version of the API: <> - -```bash -curl -X GET <>/api/<>/users -``` -```` - -### In API references - -```yaml openapi.yml -paths: - /users: - get: - description: | - The API version is <> - responses: - '200': - description: "Success" - content: - application/json: - schema: -``` - -### In docs.yml configuration - -You can also use variables in your `docs.yml` configuration. - -```yaml docs.yml -variables: - - name: "ADMIN_ROLE_NAME" - value: "admin" -``` - -```yaml docs.yml -roles: - - everyone - - <> - -navigation: - - tab: Admin - layout: - - page: Admin Dashboard - path: pages/admin-dashboard.mdx - viewers: - - <> -``` - - -Fern will not render variables in your content if they are not defined in your `docs.yml` configuration. Instead, the variable will be rendered as a literal string. - \ No newline at end of file From dd4865a0b7a22cb527b8dd085f90463fae9c7e8c Mon Sep 17 00:00:00 2001 From: chdeskur Date: Thu, 31 Jul 2025 21:33:07 -0400 Subject: [PATCH 3/3] remove file --- .../custom-components/global-variables.mdx | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 fern/products/docs/pages/component-library/custom-components/global-variables.mdx diff --git a/fern/products/docs/pages/component-library/custom-components/global-variables.mdx b/fern/products/docs/pages/component-library/custom-components/global-variables.mdx deleted file mode 100644 index 30123393b..000000000 --- a/fern/products/docs/pages/component-library/custom-components/global-variables.mdx +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: Global Variables ---- - - -Global variables are not yet available. Please contact support@buildwithfern.com if you have any feedback or questions. - - -Global variables allow you to maintain consistency across your documentation and make updates easier by centralizing commonly used values. You can define and use global variables in several places within Fern documentation. - -## Define global variables - -Define global variables in your `docs.yml` file: - -```yaml docs.yml -variables: - - name: "API_VERSION" - value: "v1" - - name: "API_URL" - value: "https://api.example.com" -``` - -## Use variables in content - -Reference variables throughout your MDX content using double angle brackets: - -### In Markdown - -````mdx use-api.mdx -Use the latest version of the API: <> - -```bash -curl -X GET <>/api/<>/users -``` -```` - -### In API references - -```yaml openapi.yml -paths: - /users: - get: - description: | - The API version is <> - responses: - '200': - description: "Success" - content: - application/json: - schema: -``` - -### In docs.yml configuration - -You can also use variables in your `docs.yml` configuration. - -```yaml docs.yml -variables: - - name: "ADMIN_ROLE_NAME" - value: "admin" -``` - -```yaml docs.yml -roles: - - everyone - - <> - -navigation: - - tab: Admin - layout: - - page: Admin Dashboard - path: pages/admin-dashboard.mdx - viewers: - - <> -``` - - -Fern will not render variables in your content if they are not defined in your `docs.yml` configuration. Instead, the variable will be rendered as a literal string. - \ No newline at end of file