Skip to content

Edit URL leads to 404 if you've specified a custom src directory #1543

@anoadragon453

Description

@anoadragon453

It looks like the code that generates the URL that users navigate to when clicking on the "Suggest an edit" button (added in #1506) assumes that your documentation is stored in a directory called src.

if let Some(ref edit_url_template) = ctx.html_config.edit_url_template {
let full_path = "src/".to_owned()
+ ch.source_path
.clone()
.unwrap_or_default()
.to_str()
.unwrap_or_default();
let edit_url = edit_url_template.replace("{path}", &full_path);
ctx.data
.insert("git_repository_edit_url".to_owned(), json!(edit_url));
}

As I've customised the directory where my documentation files are stored by using the src config option (to be docs/ instead), I end up getting a 404 when I click the "Suggest an edit" menu item button.

When I click the button, I'm lead to https://github.com/anoadragon453/examplerepo/edit/develop/src/README.md instead of https://github.com/anoadragon453/examplerepo/edit/develop/docs/README.md.

I believe the above code just needs to read from the value of the src config option, and default to "src" if it's not set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions