-
Notifications
You must be signed in to change notification settings - Fork 12
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
Generate root-relative URLs from Sphinx #105
Comments
This is harder than it looks, and related to #38. The basic issue is that the preparers can't know what prefix the content they're preparing is rendered on at prepare-time. In fact, a control repo change after the content is built could change their prefix long after the content is prepared and submitted! In order to do this properly, we'll basically need to manipulate generated URLs at presenter-time, instead. I can see three options:
Personally, I'm leaning toward option 3 as the least hacky of the three. |
@smashwilson would it be possible to have the preparer replace links with the Content ID of the item being linked to?
The presenter could then parse the content and, using the control repo's mapping tables, replace content IDs with root-relative URLs based on where on the site that content should live. |
Hmm! I like that, especially because it leads into the ability to create dynamic cross-references across content repositories. Do you think it should be a nunjucks helper call, like: <a href="{{ to('https://github.com/rackerlabs/docs-quickstart/...') }}"> Or something that we parse and replace manually ourselves? (Basically options 2 or 3 from above.) |
I think we would have to parse/replace before passing it on to Nunjucks. Nunjucks just sees the content as a big string, and won't (and probably shouldn't) do nested parsing. |
Yeah, this is what I keep going back and forth on. On one hand, it would be expensive and feel odd to parse How about this: I use a nunjucks-ish syntax for it, but implement it with a regexp? That leaves us open to expansion to full template parsing in the Distant Future ™️, keeps it light and quick for now, and gives us a reasonable-looking syntax for the intermediate documents. |
Sphinx assumes that all URLs end with a trailing slash and generates relative URLs accordingly:
These work when you visit the page with a trailing slash, but chop the final path element when you visit it without a trailing slash. Normalize URLs to be less sensitive to this.
Remaining Work
envelope.body
.envelope.next
andenvelope.previous
elements.next
andprevious
elements.contentID
element.The text was updated successfully, but these errors were encountered: