|
| 1 | +# Add a versioned docs to developer.hashicorp.com |
| 2 | + |
| 3 | +You must create PRs to update the `dev-portal` and `web-unified-docs` APIs to add a new set of versioned docs. |
| 4 | + |
| 5 | +## Update the dev-portal API |
| 6 | + |
| 7 | +1. Create a new branch for your changes in the `github.com/hashicorp/dev-portal` repository. |
| 8 | +1. In the `config/production.json` file, add a name for the new docs to the `"flags"."unified_docs_migraged_repos"` objects: |
| 9 | + |
| 10 | + ```json |
| 11 | + "flags": { |
| 12 | + "enable_datadog": true, |
| 13 | + "enable_io_beta_cta": true, |
| 14 | + "enable_hvd_on_preview_branch": false, |
| 15 | + "unified_docs_migrated_repos": [ |
| 16 | + "<existing-docs>", |
| 17 | + "<your-new-docs>" |
| 18 | + ] |
| 19 | + } |
| 20 | + ``` |
| 21 | + |
| 22 | + Use a descriptive name. The API uses this string internally. |
| 23 | + |
| 24 | +1. Make the following changes to the `src/data/<product>.json` file: |
| 25 | + - Add a base slug to the `"basePaths"` object. Take SEO into consideration when declaring the slug because it represents the first segment after the core product name in the URL, for example: `developer.hashicorp.com/terraform/<base-path-slug>` |
| 26 | + - Add the base path slug to the `"docsNavItems"` object so that it appears in the navigation. |
| 27 | + - Add an object with the following attributes: |
| 28 | + - `iconName`: For documentation, specify `"docs"`. Refer to the web engineering team for details about other supported values. |
| 29 | + - `name`: Declares the public name for the docs. |
| 30 | + - `path`: Must match the value you specified for the `"basePaths"` and `"docsNavItems"` objects. |
| 31 | + - `productSlugForLoader`: Must match the name you specified in the `"flags"."unified_docs_migraged_repos"` objects in the `config/production.json` file. |
| 32 | + |
| 33 | + The following example adds the Terraform MCP server docs: |
| 34 | + |
| 35 | + ```json |
| 36 | + { |
| 37 | + "iconName": "docs", |
| 38 | + "name": "Terraform MCP Server", |
| 39 | + "path": "mcp-server", |
| 40 | + "productSlugForLoader": "terraform-mcp-server" |
| 41 | + } |
| 42 | + ``` |
| 43 | + |
| 44 | +1. Complete the following steps to create a homepage for the docs: |
| 45 | + 1. Create the `dev-portal/src/pages/<main-product>/<new-docs>` directory path. |
| 46 | + 1. In the directory for the product docs, create a file named `[[...page]]].tsx`. |
| 47 | + 1. Add the following code to the new file: |
| 48 | + |
| 49 | + ```typescript |
| 50 | + /** |
| 51 | + * Copyright (c) HashiCorp, Inc. |
| 52 | + * SPDX-License-Identifier: MPL-2.0 |
| 53 | + */ |
| 54 | + |
| 55 | + import DocsView from 'views/docs-view' |
| 56 | + import { getRootDocsPathGenerationFunctions } from 'views/docs-view/utils/get-root-docs-path-generation-functions' |
| 57 | + |
| 58 | + const { getStaticPaths, getStaticProps } = getRootDocsPathGenerationFunctions( |
| 59 | + '<main-product-eg-terraform>', |
| 60 | + '<value-you-added-for-basePaths-and-docsNavItems>', |
| 61 | + { projectName: '<name-for-the-docs-collection>' } |
| 62 | + ) |
| 63 | + |
| 64 | + export { getStaticProps, getStaticPaths } |
| 65 | + export default DocsView |
| 66 | + ``` |
| 67 | + |
| 68 | +Before merging these changes, make changes to the `web-unified-docs` API. Refer to the [Example PRs](#example-prs) for guidance. |
| 69 | + |
| 70 | +## Update the web-unified-docs API |
| 71 | + |
| 72 | +1. Create a new branch for your changes in the `github.com/hashicorp/web-unified-docs repository` repository. |
| 73 | +1. Add the MDX files and a `nav.json` file for your new docs. |
| 74 | +1. Add an entry for the GitHub labeler so that GitHub automatically adds labels to pull requests when someone updates files in your new directory. |
| 75 | + 1. Open the `.github/labeler.yml` file. |
| 76 | + 1. Add an object using the following syntax: |
| 77 | + |
| 78 | + ```yaml |
| 79 | + <string-for-your-label>: |
| 80 | + any: |
| 81 | + changed-files: |
| 82 | + any-glob-to-any-file: [ |
| 83 | + 'content/<dir-for-your-collection>/**' |
| 84 | + ] |
| 85 | + ``` |
| 86 | + |
| 87 | +1. If you need a specific team to act as reviewers, add the group to the repository `CODEOWERS` file. The following example adds the `team-docs-packer-and-terraform ` team to the MCP server documentation: |
| 88 | + |
| 89 | + ```text |
| 90 | + content/terraform-mcp-server @hashicorp/team-docs-packer-and-terraform |
| 91 | + ``` |
| 92 | + |
| 93 | +1. Add an entry for your docs to the `productConfig.mjs` file. Use the following syntax: |
| 94 | + |
| 95 | + ```mjs |
| 96 | + '<name-you-declared-in-config/base.json-and-config/development.json-files': { |
| 97 | + assetDir: 'img', |
| 98 | + basePaths: ['<basePath-value-you-declared-in-basePaths-object'], |
| 99 | + contentDir: '<dir-where-you-added-mdx-files>', |
| 100 | + dataDir: 'data', |
| 101 | + productSlug: '<main-product-slug>', |
| 102 | + semverCoerce: semver.coerce, |
| 103 | + versionedDocs: true, |
| 104 | + websiteDir: 'website', |
| 105 | + }, |
| 106 | + ``` |
| 107 | + |
| 108 | + The following example adds the MCP server: |
| 109 | + |
| 110 | + ```mjs |
| 111 | + 'terraform-mcp-server': { |
| 112 | + assetDir: 'img', |
| 113 | + basePaths: ['mcp-server'], |
| 114 | + contentDir: 'docs', |
| 115 | + dataDir: 'data', |
| 116 | + productSlug: 'terraform', |
| 117 | + semverCoerce: semver.coerce, |
| 118 | + versionedDocs: true, |
| 119 | + websiteDir: 'website', |
| 120 | + }, |
| 121 | + ``` |
| 122 | + |
| 123 | +1. Duplicate the changes from step 5 to the `__fixtures__/productConfig.mjs` file in the root directory. This file is for testing purposes. |
| 124 | + |
| 125 | +Push your changes but do not merge until you've launched a preview to verify your updates. Refer to the [Example PRs](#example-prs) for guidance. |
| 126 | + |
| 127 | +## Preview changes |
| 128 | + |
| 129 | +Normal Vercel previews use the production state of the dev-portal API. As a result, you have to manually instruct Vercel to preview content changes in the `web-unified-docs` repository that rely on changes you make to the dev-portal API. Before you continue, request developer permissions for Vercel so that you can create variables necessary for generating previews that involve dev-portal API changes. |
| 130 | + |
| 131 | +1. Log into Vercel and go into the dev-portal project. |
| 132 | +1. Click on **Settings**, then select the **Environment Variables** in the sidebar menu. |
| 133 | +1. Click the **Create** new tab. |
| 134 | +1. Open the drop-down menu in the **Environments** section and disable **Development** so that only **Preview** is selected. |
| 135 | +1. Click **Select a custom Preview branch** and choose your dev-portal branch. |
| 136 | +1. Set the new variable key to `UNIFIED_DOCS_API`. |
| 137 | +1. Open another browser window and go to your `web-unified-docs` PR. |
| 138 | +1. In the **Vercel Previews Deployed** section, copy the URL of the **Unified Docs API preview** link, for example `https://web-unified-docs-beequ48j2-hashicorp.vercel.app/`. |
| 139 | +1. Set the `UNIFIED_DOCS_API` variable value to the **Unified Docs API preview** link and save the variable. |
| 140 | +1. Confirm that you want to redeploy the dev-portal branch preview when prompted. If Vercel does not prompt you, complete the following steps to redeploy the preview manually: |
| 141 | + 1. Click the **Deployment** tab at the top of the page. |
| 142 | + 1. Find your preview and choose **Redeploy** from the ellipses menu. |
| 143 | + |
| 144 | +After each commit to your working `web-unifed-docs` PR, you must update the variable with the new preview URL and redeploy to see changes. |
| 145 | + |
| 146 | +## Merge PRs |
| 147 | + |
| 148 | +When you are ready to publish your changes, merge the PRs in the following order: |
| 149 | + |
| 150 | +1. `web-unified-docs` |
| 151 | +1. `dev-portal` |
| 152 | + |
| 153 | +## Redeploy the website |
| 154 | + |
| 155 | +After merging your changes, you must redeploy the website. If you do not have appropriate permissions, you can ask for assistance in the `#team-web-support` channel. This process takes approximately 10 to 15 minutes to complete. Verify that your changes appear. If you have any issues, reach out to `#team-web-support`. |
| 156 | + |
| 157 | +## Example PRs |
| 158 | + |
| 159 | +Refer to the following examples for guidance on how to update the APIs. |
| 160 | + |
| 161 | +### TF migrate |
| 162 | + |
| 163 | +- https://github.com/hashicorp/web-unified-docs/pull/555 |
| 164 | +- https://github.com/hashicorp/dev-portal/pull/2808 |
| 165 | + |
| 166 | +### MCP server |
| 167 | + |
| 168 | +- https://github.com/hashicorp/dev-portal/pull/2835 |
| 169 | +- https://github.com/hashicorp/web-unified-docs/pull/949 |
0 commit comments