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
8 changes: 7 additions & 1 deletion src/project/types/website/website-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,13 @@ export async function updateSearchIndex(
// link that points to this page / sidebar. If so, inject that level
// into the crumbs as well. An attempt at improving #7803 and providing
// better crumbs
if (crumbs && sidebar) {
// deno-lint-ignore no-explicit-any
const mergeNavBarSearchCrumbs = (outputFile.format.metadata as any)
?.website?.search?.["merge-navbar-crumbs"];
if (
mergeNavBarSearchCrumbs !== false &&
crumbs && sidebar
) {
const navItem = navbarItemForSidebar(sidebar, outputFile.format);
if (navItem) {
if (typeof navItem === "object") {
Expand Down
13 changes: 8 additions & 5 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9574,6 +9574,11 @@ var require_yaml_intelligence_resources = __commonJS({
schema: "boolean",
description: "Provide button for copying search link"
},
"merge-navbar-crumbs": {
schema: "boolean",
default: true,
description: "When false, do not merge navbar crumbs into the crumbs in `search.json`."
},
"keyboard-shortcut": {
maybeArrayOf: {
string: {
Expand Down Expand Up @@ -22914,8 +22919,6 @@ var require_yaml_intelligence_resources = __commonJS({
"If <code>true</code>, force the presence of the OJS runtime. If\n<code>false</code>, force the absence instead. If unset, the OJS runtime\nis included only if OJS cells are present in the document.",
"Use the specified file as a style reference in producing a docx,\npptx, or odt file.",
"Branding information to use for this document. If a string, the path\nto a brand file. If false, don\u2019t use branding on this document. If an\nobject, an inline brand definition, or an object with light and dark\nbrand paths or definitions.",
"The path to a light brand file or an inline light brand\ndefinition.",
"The path to a dark brand file or an inline dark brand definition.",
"Theme name, theme scss file, or a mix of both.",
"The light theme name, theme scss file, or a mix of both.",
"The light theme name, theme scss file, or a mix of both.",
Expand Down Expand Up @@ -24248,12 +24251,12 @@ var require_yaml_intelligence_resources = __commonJS({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 196120,
_internalId: 194252,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 196112,
_internalId: 194244,
type: "enum",
enum: [
"png",
Expand All @@ -24269,7 +24272,7 @@ var require_yaml_intelligence_resources = __commonJS({
exhaustiveCompletions: true
},
theme: {
_internalId: 196119,
_internalId: 194251,
type: "anyOf",
anyOf: [
{
Expand Down
13 changes: 8 additions & 5 deletions src/resources/editor/tools/yaml/web-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/resources/editor/tools/yaml/yaml-intelligence-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,11 @@
"schema": "boolean",
"description": "Provide button for copying search link"
},
"merge-navbar-crumbs": {
"schema": "boolean",
"default": true,
"description": "When false, do not merge navbar crumbs into the crumbs in `search.json`."
},
"keyboard-shortcut": {
"maybeArrayOf": {
"string": {
Expand Down Expand Up @@ -15886,8 +15891,6 @@
"If <code>true</code>, force the presence of the OJS runtime. If\n<code>false</code>, force the absence instead. If unset, the OJS runtime\nis included only if OJS cells are present in the document.",
"Use the specified file as a style reference in producing a docx,\npptx, or odt file.",
"Branding information to use for this document. If a string, the path\nto a brand file. If false, don’t use branding on this document. If an\nobject, an inline brand definition, or an object with light and dark\nbrand paths or definitions.",
"The path to a light brand file or an inline light brand\ndefinition.",
"The path to a dark brand file or an inline dark brand definition.",
"Theme name, theme scss file, or a mix of both.",
"The light theme name, theme scss file, or a mix of both.",
"The light theme name, theme scss file, or a mix of both.",
Expand Down Expand Up @@ -17220,12 +17223,12 @@
"mermaid": "%%"
},
"handlers/mermaid/schema.yml": {
"_internalId": 196120,
"_internalId": 194252,
"type": "object",
"description": "be an object",
"properties": {
"mermaid-format": {
"_internalId": 196112,
"_internalId": 194244,
"type": "enum",
"enum": [
"png",
Expand All @@ -17241,7 +17244,7 @@
"exhaustiveCompletions": true
},
"theme": {
"_internalId": 196119,
"_internalId": 194251,
"type": "anyOf",
"anyOf": [
{
Expand Down
4 changes: 4 additions & 0 deletions src/resources/schema/definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,10 @@
copy-button:
schema: boolean
description: "Provide button for copying search link"
merge-navbar-crumbs:
schema: boolean
default: true
description: "When false, do not merge navbar crumbs into the crumbs in `search.json`."
keyboard-shortcut:
maybeArrayOf:
string:
Expand Down
3 changes: 3 additions & 0 deletions src/resources/schema/json-schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@
"copy-button": {
"type": "boolean"
},
"merge-navbar-crumbs": {
"type": "boolean"
},
"keyboard-shortcut": {
"anyOf": [
{
Expand Down
1 change: 1 addition & 0 deletions src/resources/types/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ The user’s cookie preferences will automatically control Google Analytics (if
search?: boolean | {
"collapse-after"?: number;
"copy-button"?: boolean;
"merge-navbar-crumbs"?: boolean;
"keyboard-shortcut"?: MaybeArrayOf<
string /* One or more keys that will act as a shortcut to launch search (single characters) */
>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
project:
type: website

website:
title: "merge-navbar-crumbs-configuration"
navbar:
left:
- href: index.qmd
text: Home
- about.qmd
sidebar:
- contents:
- section: "Level 1"
contents:
- text: "Level 2"
href: index.qmd
search:
merge-navbar-crumbs: false
format:
html:
theme:
- cosmo
- brand
css: styles.css
toc: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "About"
---

About this site
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "merge-navbar-crumbs-configuration"
---

This is a Quarto website.

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* css styles */
52 changes: 44 additions & 8 deletions tests/smoke/project/project-website.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/*
* project-website.test.ts
*
* Copyright (C) 2020-2022 Posit Software, PBC
*
*/
* project-website.test.ts
*
* Copyright (C) 2020-2022 Posit Software, PBC
*/
import { existsSync } from "../../../src/deno_ral/fs.ts";
import { join } from "../../../src/deno_ral/path.ts";

import { Metadata } from "../../../src/config/types.ts";

import { testQuartoCmd, Verify } from "../../test.ts";
import { ExecuteOutput, testQuartoCmd, Verify } from "../../test.ts";
import { docs } from "../../utils.ts";
import {
directoryEmptyButFor,
Expand All @@ -22,6 +21,7 @@ import {
kProjectWorkingDir,
kQuartoProjectFile,
} from "./common.ts";
import { assert } from "testing/asserts";

// A website project
testQuartoCmd(
Expand All @@ -32,7 +32,7 @@ testQuartoCmd(
fileExists(join(kProjectWorkingDir, "index.qmd")),
verifyYamlFile(
kQuartoProjectFile,
((yaml: unknown) => {
(yaml: unknown) => {
// Make sure there is a project yaml section
const metadata = yaml as Metadata;
if (
Expand All @@ -43,7 +43,7 @@ testQuartoCmd(
} else {
return false;
}
}),
},
),
],
{
Expand Down Expand Up @@ -86,3 +86,39 @@ testQuartoCmd(
},
},
);

const mergeNavbarCrumbsConfigSite = docs(
"websites/search/merge-navbar-crumbs-configuration",
);
const mergeNavbarCrumbsConfigSiteOutDir = join(mergeNavbarCrumbsConfigSite, outDir);
testQuartoCmd(
"render",
[mergeNavbarCrumbsConfigSite],
[
{
name: "verify-no-navbar-crumbs-in-searchjson",
verify: async (outputs: ExecuteOutput[]) => {
// Verify that the search.json file does not contain any navbar breadcrumbs
const searchJson = join(mergeNavbarCrumbsConfigSite, "_site", "search.json");
const searchJsonExists = existsSync(searchJson);
if (!searchJsonExists) {
throw new Error(`File ${searchJson} does not exist`);
}
const searchJsonContent = await Deno.readTextFile(searchJson);
const json = JSON.parse(searchJsonContent);
for (const entry of json) {
if (entry.crumbs) {
assert(entry.crumbs[0] !== "Home");
}
}
},
},
],
{
teardown: async () => {
if (existsSync(mergeNavbarCrumbsConfigSiteOutDir)) {
await Deno.remove(mergeNavbarCrumbsConfigSiteOutDir, { recursive: true });
}
},
},
);
Loading