Skip to content

Commit 9903625

Browse files
authored
Merge pull request #13725 from quarto-dev/fix/issue-13716
2 parents d5f5ad2 + ab0ea89 commit 9903625

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ All changes included in 1.9:
5454
- ([#13525](https://github.com/quarto-dev/quarto-cli/issues/13525)): Algolia Insights now uses privacy-friendly defaults: `useCookie: false` with random session tokens when cookie consent is not configured. When `cookie-consent: true` is enabled, Algolia scripts are deferred and only use cookies after user grants "tracking" consent, ensuring GDPR compliance.
5555
- ([#13547](https://github.com/quarto-dev/quarto-cli/issues/13547))`cookie-content: { type: express }` is now the default. Previously it was `type: implied`. It now means this will block cookies until the user expressly agrees to allow them (or continue blocking them if the user doesn't agree).
5656
- ([#13570](https://github.com/quarto-dev/quarto-cli/pull/13570)): Replace Twitter with Bluesky in default blog template and documentation examples. New blog projects now include Bluesky social links instead of Twitter.
57+
- ([#13716](https://github.com/quarto-dev/quarto-cli/issues/13716)): Fix draft pages showing blank during preview when pre-render scripts are configured.
5758

5859
## `publish`
5960

src/project/project-context.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ export async function projectContext(
353353
return projectFileMetadata(result, file, force);
354354
},
355355
isSingleFile: false,
356+
previewServer: renderOptions?.previewServer,
356357
diskCache: await createProjectCache(join(dir, ".quarto")),
357358
temp,
358359
cleanup: once(() => {
@@ -447,6 +448,7 @@ export async function projectContext(
447448
},
448449
notebookContext,
449450
isSingleFile: false,
451+
previewServer: renderOptions?.previewServer,
450452
diskCache: await createProjectCache(join(dir, ".quarto")),
451453
temp,
452454
cleanup: once(() => {
@@ -526,6 +528,7 @@ export async function projectContext(
526528
return projectFileMetadata(context, file, force);
527529
},
528530
isSingleFile: false,
531+
previewServer: renderOptions?.previewServer,
529532
diskCache: await createProjectCache(join(temp.baseDir, ".quarto")),
530533
temp,
531534
cleanup: once(() => {

src/project/serve/serve.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ async function internalPreviewServer(
623623
services,
624624
useFreezer: true,
625625
devServerReload: true,
626+
previewServer: true,
626627
flags: renderFlags,
627628
pandocArgs: renderPandocArgs,
628629
},

src/project/serve/watch.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ import { existsSync1 } from "../../core/file.ts";
3838
import { watchForFileChanges } from "../../core/watch.ts";
3939
import { extensionFilesFromDirs } from "../../extension/extension.ts";
4040
import { notebookContext } from "../../render/notebook/notebook-context.ts";
41-
import {
42-
kDraftMode,
43-
kDraftModeVisible,
44-
} from "../types/website/website-constants.ts";
4541

4642
interface WatchChanges {
4743
config: boolean;
@@ -69,16 +65,6 @@ export function watchProject(
6965
(await projectContext(project.dir, nbContext, renderOptions, false))!;
7066
};
7167

72-
// See if we're in draft mode
73-
if (project.config) {
74-
// If this is a website
75-
if (project.config.website) {
76-
// Switch
77-
(project.config.website as Record<string, unknown>)[kDraftMode] =
78-
kDraftModeVisible;
79-
}
80-
}
81-
8268
// proj dir
8369
const projDir = normalizePath(project.dir);
8470
const projDirHidden = projDir + "/.";

src/project/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export interface ProjectContext extends Cloneable<ProjectContext> {
122122
environment: () => Promise<ProjectEnvironment>;
123123

124124
isSingleFile: boolean;
125+
previewServer?: boolean;
125126

126127
diskCache: ProjectCache;
127128
temp: TempContext;

src/project/types/website/website-utils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import { ProjectContext } from "../../types.ts";
1515
import { warning } from "../../../deno_ral/log.ts";
1616
import { dirname, extname, join, relative } from "../../../deno_ral/path.ts";
1717
import { websiteConfigArray, websiteConfigString } from "./website-config.ts";
18-
import { kDraftMode, kDraftModeGone, kDrafts } from "./website-constants.ts";
18+
import {
19+
kDraftMode,
20+
kDraftModeGone,
21+
kDraftModeVisible,
22+
kDrafts,
23+
} from "./website-constants.ts";
1924

2025
export function removeChapterNumber(item: Element) {
2126
const numberSpan = item.querySelector(".chapter-number");
@@ -39,6 +44,11 @@ export function isProjectDraft(
3944
}
4045

4146
export function projectDraftMode(project: ProjectContext) {
47+
// Preview server always shows drafts
48+
if (project.previewServer) {
49+
return kDraftModeVisible;
50+
}
51+
// Otherwise read from config
4252
const draftMode = websiteConfigString(kDraftMode, project.config);
4353
return draftMode || kDraftModeGone;
4454
}

0 commit comments

Comments
 (0)