Skip to content

Conversation

@mcanouil
Copy link
Collaborator

@mcanouil mcanouil commented Dec 9, 2025

The update adds support for the repo-link-target and repo-link-rel attributes in the book project configuration.

The logic is similar to what was done for website/repo-actions:

  • const linkTarget = websiteConfigString(kSiteRepoLinkTarget, config);
    const linkRel = websiteConfigString(kSiteRepoLinkRel, config);
    // get the action links
    const links = repoInfo
    ? repoActionLinks(
    repoActions,
    repoInfo,
    websiteRepoBranch(config),
    source,
    language,
    issueUrl,
    )
    : [{
    text: language[kRepoActionLinksIssue]!,
    url: issueUrl!,
    icon: "chat-right",
    }];
    repoTargets.forEach((repoTarget) => {
    const actionsDiv = doc.createElement("div");
    actionsDiv.classList.add("toc-actions");
    const ulEl = doc.createElement("ul");
    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");

Fixes #13769

@mcanouil mcanouil self-assigned this Dec 9, 2025
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Dec 9, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@mcanouil mcanouil marked this pull request as ready for review December 9, 2025 09:36
Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test for this already? Otherwise, as other improvement and bug, we need one for regression test. And this is also opportunity to add test for some older feature where we did not add test thoroughly back then.

If you need help adding one, tell me.

This also helps to understand what is trying to be solved or added.

If I understand correctly, the plan is that repo-link-target and repo-link-rel sets for the github links part on each page (https://quarto.org/docs/websites/website-navigation.html#github-links) are also used for the sidebar tools: https://quarto.org/docs/books/book-output.html#sidebar-tools

Did I get it right ?

Looks good otherwise ! Thank you for those improvements!

And we may also take the opportunity for a doc update on the book part about those config being used now

@mcanouil
Copy link
Collaborator Author

mcanouil commented Dec 9, 2025

I'll add the regexes tests to look for added rel/target.

If I understand correctly, the plan is that repo-link-target and repo-link-rel sets for the github links part on each page (https://quarto.org/docs/websites/website-navigation.html#github-links) are also used for the sidebar tools: https://quarto.org/docs/books/book-output.html#sidebar-tools

Did I get it right ?

Yes, that's the case.

And we may also take the opportunity for a doc update on the book part about those config being used now

The documentation basically says to look for website navigation where the options are described thus umplying that it should have work on the tools buttons in the first place.

@mcanouil mcanouil marked this pull request as draft December 9, 2025 10:41
@cderv
Copy link
Collaborator

cderv commented Dec 9, 2025

I'll add the regexes tests to look for added rel/target.

You should be able to use the HTML element matching instead of regex.

The documentation basically says to look for website navigation where the options are described thus umplying that it should have work on the tools buttons in the first place.

Yes it says to look at it to customize the repo action "Immediately below the table of contents"

image

but it does not really say that it works (or should have worked) for link on sidebar
image

So maybe it is clear enough as it is, but it was not really documented that It should have worked on the tools buttons in the first place. 😉

Anywhow, you're right. maybe this does not need more precision that repo-link-target and repo-link-rel will apply on this sidebar tools too

@mcanouil mcanouil marked this pull request as ready for review December 10, 2025 21:42
@mcanouil
Copy link
Collaborator Author

Test added.

@mcanouil mcanouil changed the title fix: add missing support for configurable link target and rel attributes in the book project configuration fix(book): add missing support for configurable link target and rel attributes in the book project configuration Dec 10, 2025
Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you !

@cderv cderv merged commit d433605 into quarto-dev:main Dec 11, 2025
51 checks passed
@mcanouil mcanouil deleted the fix/issue13769 branch December 11, 2025 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The repo-link-target option does not work for the link to the book's GitHub repository.

3 participants