Skip to content

Commit

Permalink
Merge branch 'main' into zs.ref-for-redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
zchsh committed Sep 13, 2024
2 parents ee8a96e + 1512f68 commit 7513292
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 91 deletions.
60 changes: 0 additions & 60 deletions src/lib/__tests__/is-release-notes-page.test.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/lib/docs/is-release-notes-page.ts

This file was deleted.

17 changes: 16 additions & 1 deletion src/views/docs-view/loaders/remote-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,22 @@ export default class RemoteContentLoader implements DataLoader {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
versionMetadataList.find((e) => e.version === document.version)!
.isLatest
if (isLatest) {

/**
* We want to show "Edit on GitHub" links for public content repos only.
* Currently, HCP, PTFE and Sentinel docs are stored in private
* repositories.
*
* Note: If we need more granularity here, we could change this to be
* part of `rootDocsPath` configuration in `src/data/<product>.json`.
*/
const isPrivateContentRepo = [
'hcp-docs',
'sentinel',
'ptfe-releases',
].includes(this.opts.product)

if (isLatest && !isPrivateContentRepo) {
// GitHub only allows you to modify a file if you are on a branch, not a commit
githubFileUrl = `https://github.com/hashicorp/${this.opts.product}/blob/${this.opts.mainBranch}/${document.githubFile}`
}
Expand Down
21 changes: 2 additions & 19 deletions src/views/docs-view/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { getDeployPreviewLoader } from './utils/get-deploy-preview-loader'
import { getCustomLayout } from './utils/get-custom-layout'
import type { DocsViewPropOptions } from './utils/get-root-docs-path-generation-functions'
import { DocsViewProps } from './types'
import { isReleaseNotesPage } from 'lib/docs/is-release-notes-page'

/**
* Returns static generation functions which can be exported from a page to fetch docs data
Expand Down Expand Up @@ -411,19 +410,7 @@ export function getStaticGenerationFunctions<
validVersions.length > 0 &&
(validVersions.length > 1 || validVersions[0].version !== 'v0.0.x')

/**
* We want to show "Edit on GitHub" links for public content repos only.
* Currently, HCP and Sentinel docs are stored in private repositories.
*
* Note: If we need more granularity here, we could change this to be
* part of `rootDocsPath` configuration in `src/data/<product>.json`.
*/
const isHcp = product.slug == 'hcp'
const isSentinel = product.slug == 'sentinel'
const isPublicContentRepo = !isHcp && !isSentinel
if (isPublicContentRepo) {
layoutProps.githubFileUrl = githubFileUrl
}
layoutProps.githubFileUrl = githubFileUrl

const { hideVersionSelector, projectName } = options

Expand Down Expand Up @@ -453,11 +440,7 @@ export function getStaticGenerationFunctions<
},
projectName: projectName || null,
versions:
!hideVersionSelector &&
!isReleaseNotesPage(currentPathUnderProduct) && // toggle version dropdown
hasMeaningfulVersions
? validVersions
: null,
!hideVersionSelector && hasMeaningfulVersions ? versions : null,
}

return {
Expand Down

0 comments on commit 7513292

Please sign in to comment.