Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit in Github link has extra slash when using collections with no permalink #1463

Open
heatherbooker opened this issue Apr 23, 2024 · 3 comments
Labels

Comments

@heatherbooker
Copy link

heatherbooker commented Apr 23, 2024

Describe the bug
The "Edit in github" link produced here from gh_edit_link and other params has an extra slash in it for us, right before the collections_dir.

To Reproduce
config.yml:

collections:
  group:
    output: true
  another_group:
    output: true

just_the_docs:
  collections:
    group:
      name: Group
      nav_fold: true
    another_group:
      name: Another Group
      nav_fold: true

gh_edit_link: true
gh_edit_link_text: "Edit this page on GitHub"
gh_edit_repository: "https://github.com/our-account/our-repo"
gh_edit_branch: "main"
gh_edit_view_mode: "tree"
gh_edit_source: "handbook"

"Group" is a collection, with markdown files stored in the root level directory _group.

The URL produced is https://github.com/our-account/our-repo/tree/main/handbook//_group/FileName.md

Expected behavior
The generated link is a valid URL; concretely, I expect the extra slash before _group to be removed.
So the URL should be:https://github.com/our-account/our-repo/tree/main/handbook/_group/FileName.md

Additional context
If I edit the footer component and remove the slash within this if:

{% if page.collection and site.collections_dir %}/{{ site.collections_dir }}{% endif %}

, it renders the URL as I expect, with a single slash preceeding the collection directory.

@heatherbooker
Copy link
Author

Ooh, interestingly, it turns out Github opens these links with extra slashes just fine; it was that we had a problem elsewhere in our gh_edit_* configs. So I'd class this as weird behaviour, but no longer as important to fix!

@mattxwang
Copy link
Member

Hi @heatherbooker, thank you for submitting an issue! I appreciate the context that you've provided in helping me better understand this issue. Could I ask: are you setting the site.collections_dir variable anywhere in your _config.yml? I wonder if this is an empty collections_dir (but non-nil) value that's being interpreted as truthy, and is accidentally tripping this if block.

@heatherbooker
Copy link
Author

Thanks for your reply! No, we don't set collections_dir anywhere in our config. But I think maybe it is being set somewhere behind the scenes, to _group (because how else is the collection name getting into the URL?).

(btw I edited my original post because I accidentally used 2 different names for group; now it is consistent.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants