alphagov / tech-docs-gem

Gem to distribute the tech docs project
https://tdt-documentation.london.cloudapps.digital/
MIT License
15 stars 38 forks source link

Add an "edit this page" link as a layout option #171

Closed digitalronin closed 4 years ago

digitalronin commented 4 years ago

It would be great if we could put an "edit this page" link in the header/footer of our documentation pages, to make it as quick and easy as possible for authorised users to submit minor changes such as typo corrections.

This could be done by configuring a repository base URL and an edit link URL template in the site config, and then having a custom "edit this page" tag, interpreted at site build time, which used the URL template and the current source filename to populate the link target.

For example, this page: https://runbooks.cloud-platform.service.justice.gov.uk/create-cluster.html

...would have a link to this URL: https://github.com/ministryofjustice/cloud-platform/edit/master/runbooks/source/create-cluster.html.md.erb

I had a quick look, but couldn't see where to hook into the relevant lifecycle events in the publishing of a techdocs site. If you can provide any pointers, I'd be happy to push this forward.

tijmenb commented 4 years ago

Hey @digitalronin, this exists! It's the show_contribution_banner in config/tech-docs.yml. Your site also seems to have it enabled (the "View source" link at the bottom), but it doesn't work because it's in a subdirectory so the links 404.

I would suggest to add a extra config that specifies the subdirectory in the repo that the middleman sites lives in, and use that in https://github.com/alphagov/tech-docs-gem/blob/73d658e5f60eaae1ea5579b9550d5d3a0c35d070/lib/govuk_tech_docs/contribution_banner.rb#L55 to make it work for your site.

digitalronin commented 4 years ago

Hi @tijmenb Thanks so much for the prompt reply.

You definitely pointed me in the right direction. In the end, I went for this approach: https://github.com/ministryofjustice/cloud-platform/pull/1714

...mainly because that was easier than figuring out how to add a new config setting and then hook it into the contribution banner module.