Skip to content

Commit

Permalink
Move PTFE detection logic from server.ts to loader
Browse files Browse the repository at this point in the history
  • Loading branch information
rmainwork committed Sep 9, 2024
1 parent c991e25 commit 66adda2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 7 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,13 @@ 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 shouldn't be showing "Edit on GitHub" links for PTFE because
// it takes people to a 404 on GitHub if they're not members of the
// GitHub org
const isPtfe = document.product === 'ptfe-releases'

if (isLatest && !isPtfe) {
// 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
4 changes: 1 addition & 3 deletions src/views/docs-view/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,7 @@ export function getStaticGenerationFunctions<
* part of `rootDocsPath` configuration in `src/data/<product>.json`.
*/
const isPublicContentRepo =
product.slug !== 'hcp' &&
product.slug !== 'sentinel' &&
product.slug + currentPathUnderProduct !== 'terraform/enterprise'
product.slug !== 'hcp' && product.slug !== 'sentinel'
if (isPublicContentRepo) {
layoutProps.githubFileUrl = githubFileUrl
}
Expand Down

0 comments on commit 66adda2

Please sign in to comment.