Skip to content

Commit 729fee6

Browse files
authored
Merge pull request #148 from USACE-RMC/fix/preview-draft-notice-wording
[Content] Show review-stage draft wording in PR previews
2 parents 472e210 + 4acb3f6 commit 729fee6

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎docusaurus.config.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ export default {
5757
onBrokenAnchors: 'warn',
5858
url: process.env.DOCUSAURUS_URL || 'https://USACE-RMC.github.io',
5959
baseUrl: process.env.DOCUSAURUS_BASE_URL || '/RMC-Software-Documentation/',
60+
customFields: {
61+
isPreview: process.env.DOCUSAURUS_IS_PREVIEW === 'true',
62+
},
6063
favicon: 'img/USACE.png',
6164
organizationName: 'USACE-RMC', // Your GitHub organization or username
6265
projectName: 'RMC-Software-Documentation', // Your project name, make sure this matches your GitHub repo name

‎src/components/DraftNotice.js‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useLocation } from '@docusaurus/router';
22
import useBaseUrl from '@docusaurus/useBaseUrl';
3+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
34
import latestVersions from '@site/static/versions/latestVersions.json';
45
import { draftDocs } from '../draftDocs';
56

@@ -20,6 +21,13 @@ import { draftDocs } from '../draftDocs';
2021
*/
2122

2223
export const DRAFT_STATUS_TEXT = 'This document is pending final approval by the RMC Director.';
24+
// A PR preview shows the draft while it is still in review, before the Director stage.
25+
export const PREVIEW_DRAFT_STATUS_TEXT = 'Draft for review. This document has not been approved for publication.';
26+
27+
function useDraftStatusText() {
28+
const { siteConfig } = useDocusaurusContext();
29+
return siteConfig.customFields?.isPreview ? PREVIEW_DRAFT_STATUS_TEXT : DRAFT_STATUS_TEXT;
30+
}
2331

2432
function getDocInfo(pathname, docsBase) {
2533
// docsBase is derived from siteConfig.baseUrl, so this resolves under every
@@ -63,12 +71,13 @@ export function useIsDraftDoc() {
6371
*/
6472
export const DraftStatusStrip = () => {
6573
const isDraft = useIsDraftDoc();
74+
const statusText = useDraftStatusText();
6675
if (!isDraft) return null;
6776

6877
return (
6978
<div className="draft-strip-anchor">
7079
<div className="draft-strip" role="note" aria-label="Document status">
71-
{DRAFT_STATUS_TEXT}
80+
{statusText}
7281
</div>
7382
</div>
7483
);
@@ -84,6 +93,7 @@ export const DraftStatusStrip = () => {
8493
*/
8594
export const DraftPrintFrame = ({ children }) => {
8695
const isDraft = useIsDraftDoc();
96+
const statusText = useDraftStatusText();
8797
if (!isDraft) return <>{children}</>;
8898

8999
return (
@@ -92,7 +102,7 @@ export const DraftPrintFrame = ({ children }) => {
92102
<tr>
93103
<td>
94104
<div className="draft-print-frame__band" aria-hidden="true">
95-
{DRAFT_STATUS_TEXT}
105+
{statusText}
96106
</div>
97107
</td>
98108
</tr>
@@ -106,7 +116,7 @@ export const DraftPrintFrame = ({ children }) => {
106116
<tr>
107117
<td>
108118
<div className="draft-print-frame__band draft-print-frame__band--foot" aria-hidden="true">
109-
{DRAFT_STATUS_TEXT}
119+
{statusText}
110120
</div>
111121
</td>
112122
</tr>

0 commit comments

Comments
 (0)