Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ All changes included in 1.6:
- ([#10567](https://github.com/quarto-dev/quarto-cli/issues/10567)): Generate breadcrumbs correctly for documents using a level-1 heading as the title.
- ([#10616](https://github.com/quarto-dev/quarto-cli/issues/10268)): Add a `z-index` setting to the 'back to top' button to ensure it is always visible.
- ([#10864](https://github.com/quarto-dev/quarto-cli/issues/10864)): Support detection of `og:image:alt` attribute from auto-discovered images.
- ([#9905](https://github.com/quarto-dev/quarto-cli/issues/9905)): Setting `search: false` in `navbar` config for `website` in `_quarto.yml` correctly opt-out sidebar.

### Quarto Blog

Expand Down
4 changes: 3 additions & 1 deletion src/project/types/website/website-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,9 @@ async function navbarEjsData(
const searchOpts = await searchOptions(project);
const data: Navbar = {
...navbar,
search: searchOpts && searchOpts.location === "navbar"
search: navbar.search !== undefined
? navbar.search
: searchOpts && searchOpts.location === "navbar"
? searchOpts.type
: false,
background: navbar.background || "primary",
Expand Down
2 changes: 2 additions & 0 deletions tests/docs/search/issue-9905/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.quarto/
_site/
1 change: 1 addition & 0 deletions tests/docs/search/issue-9905/navbar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
14 changes: 14 additions & 0 deletions tests/docs/search/issue-9905/navbar/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
project:
type: website

website:
title: "search opt out"
search:
location: sidebar
navbar:
search: false
left:
- href: index.qmd
text: Home

format: html
7 changes: 7 additions & 0 deletions tests/docs/search/issue-9905/navbar/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "search opt out"
---

This is a Quarto website.

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.
1 change: 1 addition & 0 deletions tests/docs/search/issue-9905/sidebar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
15 changes: 15 additions & 0 deletions tests/docs/search/issue-9905/sidebar/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project:
type: website

website:
title: "search opt out"
search:
location: sidebar
sidebar:
search: false
contents:
- section: "Basics"
contents:
- index.qmd

format: html
7 changes: 7 additions & 0 deletions tests/docs/search/issue-9905/sidebar/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "search opt out"
---

This is a Quarto website.

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.
2 changes: 1 addition & 1 deletion tests/smoke/extensions/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ for (const extUrl of extUrls) {
Deno.removeSync("_extensions", { recursive: true });
return Promise.resolve();
},
santize: {
sanitize: {
resources: false,
},
},
Expand Down
21 changes: 12 additions & 9 deletions tests/smoke/site/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { existsSync } from "../../../src/deno_ral/fs.ts";
import { dirname } from "../../../src/deno_ral/path.ts";
import { testQuartoCmd, Verify } from "../../test.ts";
import { testQuartoCmd, Verify, TestContext, mergeTestContexts } from "../../test.ts";
import { projectOutputForInput } from "../../utils.ts";
import { ensureHtmlElements, noErrorsOrWarnings } from "../../verify.ts";

Expand All @@ -14,6 +14,7 @@ export const testSite = (
renderTarget: string,
includeSelectors: string[],
excludeSelectors: string[],
additionalContext?: TestContext,
...verify: Verify[]
) => {
const output = projectOutputForInput(input);
Expand All @@ -24,18 +25,20 @@ export const testSite = (
excludeSelectors,
);

const baseContext: TestContext = {
teardown: async () => {
const siteDir = dirname(output.outputPath);
if (existsSync(siteDir)) {
await Deno.remove(siteDir, { recursive: true });
}
},
};

// Run the command
testQuartoCmd(
"render",
[renderTarget],
[noErrorsOrWarnings, verifySel, ...verify],
{
teardown: async () => {
const siteDir = dirname(output.outputPath);
if (existsSync(siteDir)) {
await Deno.remove(siteDir, { recursive: true });
}
},
},
mergeTestContexts(baseContext, additionalContext),
);
};
12 changes: 12 additions & 0 deletions tests/smoke/website/search.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* drafts.test.ts
*
* Copyright (C) 2020-2022 Posit Software, PBC
*
*/
import { docs } from "../../utils.ts";
import { testSite } from "../site/site.ts";

await testSite(docs("search/issue-9905/navbar/index.qmd"), docs("search/issue-9905/navbar"), [], ["div#quarto-search"])
await testSite(docs("search/issue-9905/sidebar/index.qmd"), docs("search/issue-9905/sidebar"), [], ["div.sidebar-search"]);

48 changes: 44 additions & 4 deletions tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface TestContext {
cwd?: () => string;

// Control of underlying sanitizer
santize?: { resources?: boolean; ops?: boolean; exit?: boolean };
sanitize?: { resources?: boolean; ops?: boolean; exit?: boolean };

// control if test is ran or skipped
ignore?: boolean;
Expand All @@ -59,6 +59,46 @@ export interface TestContext {
env?: Record<string, string>;
}

// Allow to merge test contexts in Tests helpers
export function mergeTestContexts(baseContext: TestContext, additionalContext?: TestContext): TestContext {
if (!additionalContext) {
return baseContext;
}

return {
// override name if provided
name: additionalContext.name || baseContext.name,
// combine prereq conditions
prereq: async () => {
const baseResult = !baseContext.prereq || await baseContext.prereq();
const additionalResult = !additionalContext.prereq || await additionalContext.prereq();
return baseResult && additionalResult;
},
// run teardowns in reverse order
teardown: async () => {
if (baseContext.teardown) await baseContext.teardown();
if (additionalContext.teardown) await additionalContext.teardown();
},
// run setups in order
setup: async () => {
if (additionalContext.setup) await additionalContext.setup();
if (baseContext.setup) await baseContext.setup();
},
// override cwd if provided
cwd: additionalContext.cwd || baseContext.cwd,
// merge sanitize options
sanitize: {
resources: additionalContext.sanitize?.resources ?? baseContext.sanitize?.resources,
ops: additionalContext.sanitize?.ops ?? baseContext.sanitize?.ops,
exit: additionalContext.sanitize?.exit ?? baseContext.sanitize?.exit,
},
// override ignore if provided
ignore: additionalContext.ignore ?? baseContext.ignore,
// merge env with additional context taking precedence
env: { ...baseContext.env, ...additionalContext.env },
};
}

export function testQuartoCmd(
cmd: string,
args: string[],
Expand Down Expand Up @@ -125,9 +165,9 @@ export function test(test: TestDescriptor) {
? `[${test.type}] > ${test.name} (${test.context.name})`
: `[${test.type}] > ${test.name}`;

const sanitizeResources = test.context.santize?.resources;
const sanitizeOps = test.context.santize?.ops;
const sanitizeExit = test.context.santize?.exit;
const sanitizeResources = test.context.sanitize?.resources;
const sanitizeOps = test.context.sanitize?.ops;
const sanitizeExit = test.context.sanitize?.exit;
const ignore = test.context.ignore;
const userSession = !runningInCI();

Expand Down
2 changes: 1 addition & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ export function fileLoader(...path: string[]) {
// On Windows, `quarto.cmd` needs to be explicit in `execProcess()`
export function quartoDevCmd(): string {
return Deno.build.os === "windows" ? "quarto.cmd" : "quarto";
}
}
Loading