diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 7a59fe013bb..01464672b65 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -54,6 +54,7 @@ All changes included in 1.9: - ([#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. - ([#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). - ([#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. +- ([#13716](https://github.com/quarto-dev/quarto-cli/issues/13716)): Fix draft pages showing blank during preview when pre-render scripts are configured. ## `publish` diff --git a/src/project/project-context.ts b/src/project/project-context.ts index 0049122c79d..1df4275d162 100644 --- a/src/project/project-context.ts +++ b/src/project/project-context.ts @@ -353,6 +353,7 @@ export async function projectContext( return projectFileMetadata(result, file, force); }, isSingleFile: false, + previewServer: renderOptions?.previewServer, diskCache: await createProjectCache(join(dir, ".quarto")), temp, cleanup: once(() => { @@ -447,6 +448,7 @@ export async function projectContext( }, notebookContext, isSingleFile: false, + previewServer: renderOptions?.previewServer, diskCache: await createProjectCache(join(dir, ".quarto")), temp, cleanup: once(() => { @@ -526,6 +528,7 @@ export async function projectContext( return projectFileMetadata(context, file, force); }, isSingleFile: false, + previewServer: renderOptions?.previewServer, diskCache: await createProjectCache(join(temp.baseDir, ".quarto")), temp, cleanup: once(() => { diff --git a/src/project/serve/serve.ts b/src/project/serve/serve.ts index 3a5034cc5a0..13d968ac6cd 100644 --- a/src/project/serve/serve.ts +++ b/src/project/serve/serve.ts @@ -623,6 +623,7 @@ async function internalPreviewServer( services, useFreezer: true, devServerReload: true, + previewServer: true, flags: renderFlags, pandocArgs: renderPandocArgs, }, diff --git a/src/project/serve/watch.ts b/src/project/serve/watch.ts index 2f0b67fc116..69ffe6f5459 100644 --- a/src/project/serve/watch.ts +++ b/src/project/serve/watch.ts @@ -38,10 +38,6 @@ import { existsSync1 } from "../../core/file.ts"; import { watchForFileChanges } from "../../core/watch.ts"; import { extensionFilesFromDirs } from "../../extension/extension.ts"; import { notebookContext } from "../../render/notebook/notebook-context.ts"; -import { - kDraftMode, - kDraftModeVisible, -} from "../types/website/website-constants.ts"; interface WatchChanges { config: boolean; @@ -69,16 +65,6 @@ export function watchProject( (await projectContext(project.dir, nbContext, renderOptions, false))!; }; - // See if we're in draft mode - if (project.config) { - // If this is a website - if (project.config.website) { - // Switch - (project.config.website as Record)[kDraftMode] = - kDraftModeVisible; - } - } - // proj dir const projDir = normalizePath(project.dir); const projDirHidden = projDir + "/."; diff --git a/src/project/types.ts b/src/project/types.ts index ecf5c60ae83..2d2b73faf15 100644 --- a/src/project/types.ts +++ b/src/project/types.ts @@ -122,6 +122,7 @@ export interface ProjectContext extends Cloneable { environment: () => Promise; isSingleFile: boolean; + previewServer?: boolean; diskCache: ProjectCache; temp: TempContext; diff --git a/src/project/types/website/website-utils.ts b/src/project/types/website/website-utils.ts index 0194c1dbd19..01d42b7c8e4 100644 --- a/src/project/types/website/website-utils.ts +++ b/src/project/types/website/website-utils.ts @@ -15,7 +15,12 @@ import { ProjectContext } from "../../types.ts"; import { warning } from "../../../deno_ral/log.ts"; import { dirname, extname, join, relative } from "../../../deno_ral/path.ts"; import { websiteConfigArray, websiteConfigString } from "./website-config.ts"; -import { kDraftMode, kDraftModeGone, kDrafts } from "./website-constants.ts"; +import { + kDraftMode, + kDraftModeGone, + kDraftModeVisible, + kDrafts, +} from "./website-constants.ts"; export function removeChapterNumber(item: Element) { const numberSpan = item.querySelector(".chapter-number"); @@ -39,6 +44,11 @@ export function isProjectDraft( } export function projectDraftMode(project: ProjectContext) { + // Preview server always shows drafts + if (project.previewServer) { + return kDraftModeVisible; + } + // Otherwise read from config const draftMode = websiteConfigString(kDraftMode, project.config); return draftMode || kDraftModeGone; }