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

fix: generate multipage TOC with http_prefix #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lhokktyn
Copy link

@lhokktyn lhokktyn commented Apr 9, 2019

Please see replication steps here: alphagov/tech-docs-template#183 (comment)

Whilst the test already in place appears to work, I'm not sure it is covering my particular case because when I build my site it is not generating files within a prefixed folder, so I may need a bit of guidance to write additional test (or correct my approach!) ...

For example, when http_prefix=/prefix/, given my source/:

|- source/
|--documentation/
|--index.html.md.erb
|--page2.html.md.erb

This is generating files in the build directory as so:

|- build/
|--index.html
|--page2.html

But the test in place appears to expect generated assets to be:

|- build/
|--prefix/index.html
|--prefix/page2.html

The attached PR does fix the issue for me, however.

@NickColley
Copy link
Contributor

Hello @lhokktyn,

Do you have time to finish this work in progress up, or should we close this for now (and consider raising a bug report instead)?

@lhokktyn lhokktyn changed the title WIP: fix: generate multipage TOC with http_prefix fix: generate multipage TOC with http_prefix Feb 12, 2020
@lhokktyn
Copy link
Author

Hi @NickColley , apologies for the very tardy reply!

I've been using this fix locally for a few months and it works for our use case, but as I'm an amateur Rubyer and my experience with the tech docs gem is very light touch, I was hoping someone more experienced in these matter might be free to review this fix and test if it'll apply correctly in more common usage scenarios.

Cheers

@djn72
Copy link

djn72 commented Mar 4, 2020

Is there any movement on this?

We have multiple teams/projects relying on this fork/fix to build docs within GitLab Pages and it'd be great to see this included so we can tidy up and use a tagged version from the official repo :-)

@edjannoo
Copy link

I'd like to add my voice to getting this resolved in the main codebase. At HMRC we're building rich content guides that are hosted within the Developer Hub and therefore are deployed under a custom path prefix. We've had to override the multi_page_table_of_contents function in our local config.rb with the code from this PR (thanks @lhokktyn!) to make this work.

@odlp
Copy link
Contributor

odlp commented Sep 30, 2020

We'd also benefit from this fix over on the API catalogue. Please let me know if I can be of any assistance.

@TomTucka
Copy link

Any idea when this will be merged? Causing us some issues over at MoJ

@odlp
Copy link
Contributor

odlp commented Nov 10, 2020

@TomTucka I can't speak to when this will be merged, but I did create a http-prefix-support branch in this repo which combines this PR + #196 + #197 which are other http_prefix related fixes. It can be sourced like this:

gem "govuk_tech_docs", git: "https://github.com/alphagov/tech-docs-gem.git", branch: "http-prefix-support"

@huwd
Copy link
Member

huwd commented Oct 9, 2024

this is a v4 candidate, seems useful and small enough to review (@lhokktyn - sincere apologies you've had to wait so long, there's a group of us trying to return to do a stint of maintenance here) - I'll try and review properly this week.

@huwd huwd added the v4 Candidate features for v4 label Oct 9, 2024
@@ -19,10 +19,18 @@ def single_page_table_of_contents(html, url: "", max_level: nil)
end

def multi_page_table_of_contents(resources, current_page, config, current_page_html = nil)
# Determine
home_url =
Copy link
Contributor

Choose a reason for hiding this comment

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

We could potentially extract an helper method:

def determine_home_url(http_prefix)
  http_prefix.end_with?("/") ? http_prefix : "#{http_prefix}/"
end

And then within multi_page_table_of_contents we could use it:

home_url = determine_home_url(config[:http_prefix])

Copy link
Contributor

@marcotranchino marcotranchino left a comment

Choose a reason for hiding this comment

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

I have made a small optional suggestion, but anyway this LGTM 👍

@huwd huwd removed the v4 Candidate features for v4 label Oct 22, 2024
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.

8 participants