Skip to content

Commit

Permalink
Support new windows for repo links
Browse files Browse the repository at this point in the history
Use `repo-link-target` and `repo-link-rel` to add target and rel attrtibutes to repo-action links.

Fixes #5964
  • Loading branch information
dragonstyle committed Dec 12, 2023
1 parent f0aa38e commit d9bef2f
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 35 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
- ([#5756](https://github.com/quarto-dev/quarto-cli/issues/5756)): Add `rel="..."` resolution to navbar tools.
- ([#5763](https://github.com/quarto-dev/quarto-cli/issues/5763)): Add support for a keyboard shortcut to launch search (defaults to `f` or `/`). Use `search` > `keyboard-shortcut` to override with your own key(s).
- ([#5932](https://github.com/quarto-dev/quarto-cli/issues/5932)): Correct Open Graph metadata key name for `og:site_name`
- ([#5964](https://github.com/quarto-dev/quarto-cli/issues/5964)): Add support for `repo-link-target` and `repo-link-rel` to control the corresponding attributes of repo-action links.
- ([#6432](https://github.com/quarto-dev/quarto-cli/issues/6432)): Don't decorate navigation tools with external link icon (we generally don't decorate navigation chrome in this way)
- ([#6703](https://github.com/quarto-dev/quarto-cli/issues/6703)): Warn users when a `theme` key in a document is being ignored.
- ([#6704](https://github.com/quarto-dev/quarto-cli/issues/6704)): Use the correct title when there are duplicate sidebar `href` targets
Expand Down
4 changes: 4 additions & 0 deletions src/project/types/book/book-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import {
kSiteReaderMode,
kSiteRepoActions,
kSiteRepoBranch,
kSiteRepoLinkRel,
kSiteRepoLinkTarget,
kSiteRepoSubdir,
kSiteRepoUrl,
kSiteSidebar,
Expand Down Expand Up @@ -128,6 +130,8 @@ export async function bookProjectConfig(
site[kSiteUrl] = book[kSiteUrl];
site[kSitePath] = book[kSitePath];
site[kSiteRepoUrl] = book[kSiteRepoUrl];
site[kSiteRepoLinkTarget] = book[kSiteRepoLinkTarget];
site[kSiteRepoLinkRel] = book[kSiteRepoLinkRel];
site[kSiteRepoSubdir] = book[kSiteRepoSubdir];
site[kSiteRepoBranch] = book[kSiteRepoBranch];
site[kSiteRepoActions] = book[kSiteRepoActions];
Expand Down
2 changes: 2 additions & 0 deletions src/project/types/website/website-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type WebsiteConfigKey =
| "site-url"
| "site-path"
| "repo-url"
| "repo-link-target"
| "repo-link-rel"
| "repo-subdir"
| "repo-branch"
| "repo-actions"
Expand Down
11 changes: 6 additions & 5 deletions src/project/types/website/website-constants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*
* website-constants.ts
*
* Copyright (C) 2022 Posit Software, PBC
*
*/
* website-constants.ts
*
* Copyright (C) 2022 Posit Software, PBC
*/

export const kWebsite = "website";

Expand All @@ -14,6 +13,8 @@ export const kSiteFavicon = "favicon";
export const kSiteRepoUrl = "repo-url";
export const kSiteRepoSubdir = "repo-subdir";
export const kSiteRepoBranch = "repo-branch";
export const kSiteRepoLinkTarget = "repo-link-target";
export const kSiteRepoLinkRel = "repo-link-rel";
export const kSiteIssueUrl = "issue-url";
export const kSiteRepoActions = "repo-actions";
export const kSiteReaderMode = "reader-mode";
Expand Down
11 changes: 11 additions & 0 deletions src/project/types/website/website-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ import {
kSitePageNavigation,
kSiteReaderMode,
kSiteRepoActions,
kSiteRepoLinkRel,
kSiteRepoLinkTarget,
kSiteRepoUrl,
kSiteSidebar,
kWebsite,
Expand Down Expand Up @@ -698,6 +700,9 @@ function handleRepoLinks(
}

if (repoTarget) {
const linkTarget = websiteConfigString(kSiteRepoLinkTarget, config);
const linkRel = websiteConfigString(kSiteRepoLinkRel, config);

// get the action links
const links = repoInfo
? repoActionLinks(
Expand All @@ -720,6 +725,12 @@ function handleRepoLinks(
links.forEach((link) => {
const a = doc.createElement("a");
a.setAttribute("href", link.url);
if (linkTarget) {
a.setAttribute("target", linkTarget);
}
if (linkRel) {
a.setAttribute("rel", linkRel);
}
a.classList.add("toc-action");
a.innerHTML = link.text;

Expand Down
34 changes: 24 additions & 10 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9243,6 +9243,16 @@ var require_yaml_intelligence_resources = __commonJS({
description: "Base URL for website source code repository"
}
},
"repo-link-target": {
string: {
description: "The value of the target attribute for repo links"
}
},
"repo-link-rel": {
string: {
description: "The value of the rel attribute for repo links"
}
},
"repo-subdir": {
string: {
description: "Subdirectory of repository containing website"
Expand Down Expand Up @@ -19588,10 +19598,11 @@ var require_yaml_intelligence_resources = __commonJS({
"Whether to show navigation breadcrumbs for pages more than 1 level\ndeep",
"Shared page footer",
"Default site thumbnail image for <code>twitter</code>\n/<code>open-graph</code>",
"Default site thumbnail image alt text for <code>twitter</code>\n/<code>open-graph</code>",
"Publish open graph metadata",
"Publish twitter card metadata",
"A list of other links to appear below the TOC.",
"A list of codes links to appear with this document.",
"A list of code links to appear with this document.",
"Book title",
"Description metadata for HTML version of book",
"The path to the favicon for this website",
Expand Down Expand Up @@ -19719,10 +19730,11 @@ var require_yaml_intelligence_resources = __commonJS({
"Whether to show navigation breadcrumbs for pages more than 1 level\ndeep",
"Shared page footer",
"Default site thumbnail image for <code>twitter</code>\n/<code>open-graph</code>",
"Default site thumbnail image alt text for <code>twitter</code>\n/<code>open-graph</code>",
"Publish open graph metadata",
"Publish twitter card metadata",
"A list of other links to appear below the TOC.",
"A list of codes links to appear with this document.",
"A list of code links to appear with this document.",
"Book subtitle",
"Author or authors of the book",
"Author or authors of the book",
Expand Down Expand Up @@ -21599,7 +21611,7 @@ var require_yaml_intelligence_resources = __commonJS({
"Play a subtle sound when changing slides",
{
short: "Slides that are too tall to fit within a single page will expand onto\nmultiple pages",
long: "\u201CSlides that are too tall to fit within a single page will expand\nonto multiple pages. You can limit how many pages a slide may expand to\nusing this option\u201D"
long: "Slides that are too tall to fit within a single page will expand onto\nmultiple pages. You can limit how many pages a slide may expand to using\nthis option."
},
"Prints each fragment on a separate slide",
{
Expand Down Expand Up @@ -21717,8 +21729,8 @@ var require_yaml_intelligence_resources = __commonJS({
},
"Specify the number of section levels to include in the table of\ncontents. The default is 3",
{
short: "Location for table of contents (<code>body</code>, <code>left</code>,\n<code>right</code> (default), \u2018left-body\u2019, \u2018right-body\u2019).",
long: "Location for table of contents (<code>body</code>, <code>left</code>,\n<code>right</code> (default), \u2018left-body\u2019, \u2018right-body\u2019).\n<code>body</code> - Show the Table of Contents in the center body of the\ndocument. <code>left</code> - Show the Table of Contents in left margin\nof the document. <code>right</code> - Show the Table of Contents in\nright margin of the document. <code>left-body</code> - Show two Tables\nof Contents in both the center body and the left margin of the document.\n<code>right-body</code> - Show two Tables of Contents in both the center\nbody and the right margin of the document."
short: "Location for table of contents (<code>body</code>, <code>left</code>,\n<code>right</code> (default), <code>left-body</code>,\n<code>right-body</code>).",
long: "Location for table of contents:"
},
"The title used for the table of contents.",
"Specifies the depth of items in the table of contents that should be\ndisplayed as expanded in HTML output. Use <code>true</code> to expand\nall or <code>false</code> to collapse all.",
Expand Down Expand Up @@ -21886,10 +21898,11 @@ var require_yaml_intelligence_resources = __commonJS({
"Whether to show navigation breadcrumbs for pages more than 1 level\ndeep",
"Shared page footer",
"Default site thumbnail image for <code>twitter</code>\n/<code>open-graph</code>",
"Default site thumbnail image alt text for <code>twitter</code>\n/<code>open-graph</code>",
"Publish open graph metadata",
"Publish twitter card metadata",
"A list of other links to appear below the TOC.",
"A list of codes links to appear with this document.",
"A list of code links to appear with this document.",
"Book subtitle",
"Author or authors of the book",
"Author or authors of the book",
Expand Down Expand Up @@ -22201,10 +22214,11 @@ var require_yaml_intelligence_resources = __commonJS({
"Whether to show navigation breadcrumbs for pages more than 1 level\ndeep",
"Shared page footer",
"Default site thumbnail image for <code>twitter</code>\n/<code>open-graph</code>",
"Default site thumbnail image alt text for <code>twitter</code>\n/<code>open-graph</code>",
"Publish open graph metadata",
"Publish twitter card metadata",
"A list of other links to appear below the TOC.",
"A list of codes links to appear with this document.",
"A list of code links to appear with this document.",
"Book subtitle",
"Author or authors of the book",
"Author or authors of the book",
Expand Down Expand Up @@ -22595,12 +22609,12 @@ var require_yaml_intelligence_resources = __commonJS({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 180643,
_internalId: 180595,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 180635,
_internalId: 180587,
type: "enum",
enum: [
"png",
Expand All @@ -22616,7 +22630,7 @@ var require_yaml_intelligence_resources = __commonJS({
exhaustiveCompletions: true
},
theme: {
_internalId: 180642,
_internalId: 180594,
type: "anyOf",
anyOf: [
{
Expand Down
34 changes: 24 additions & 10 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.

Loading

0 comments on commit d9bef2f

Please sign in to comment.