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

Make pkgdown add class=col-md-9 in articles #2045

Closed
mrcaseb opened this issue Feb 18, 2022 · 7 comments · Fixed by #2048
Closed

Make pkgdown add class=col-md-9 in articles #2045

mrcaseb opened this issue Feb 18, 2022 · 7 comments · Fixed by #2048
Labels
articles ✍️ reprex needs a minimal reproducible example

Comments

@mrcaseb
Copy link
Contributor

mrcaseb commented Feb 18, 2022

There is this line in the content-article.html template that should be able to add the col-md-9 class to main but I am not able to actually toggle it.

<main id="main" $if(toc)$class="col-md-9"$endif$>

I can't find any BS5 pkgdown site that uses that class for the main content in articles.

Sorry, it's hard to provide a reprex but it seems like toc: true in the article meta data doesn't have any effect.

@mrcaseb
Copy link
Contributor Author

mrcaseb commented Feb 18, 2022

In other words:

This test

# We don't have a main with .col-md-9 if TOC isn't present
xpath_contents <- ".//main[contains(@class, 'col-md-9')]"
expect_equal(xpath_length(toc_false_html, xpath_contents), 0)

passes, even if we do

toc: true 

here

@maelle
Copy link
Collaborator

maelle commented Feb 21, 2022

Related (sort of) https://twitter.com/jimhester_/status/1488953531642040327

I wonder whether the problem comes from using Pandoc vs Mustache templating. #2048 (pkgdown does not use rmarkdown's toc at all).

@hadley
Copy link
Member

hadley commented May 31, 2022

@mrcaseb can you show what the problem is?

@hadley hadley added articles ✍️ reprex needs a minimal reproducible example labels May 31, 2022
@mrcaseb
Copy link
Contributor Author

mrcaseb commented Jun 1, 2022

@mrcaseb can you show what the problem is?

It started in this thread with the desire to make the main content of pkgdown sites wider on bigger screens. https://twitter.com/jimhester_/status/1488953531642040327?s=20&t=gsW4dxCbUHnRUkqDwspOTA

I've added this css to one of my pkgdown sites
https://github.com/nflverse/nflplotR/blob/e169b89fe3d3645111d78cf734cd0759be2493dd/pkgdown/extra.css#L5-L15

It works fine for the homepage,
image

or for the changelog
image

But it fails for an article. The toc is at the end of the page on that article site.
image

@hadley
Copy link
Member

hadley commented Jun 1, 2022

Thanks for that summary. Can you please now connect it to why col-md-9 would help?

@mrcaseb
Copy link
Contributor Author

mrcaseb commented Jun 1, 2022

Thanks for that summary. Can you please now connect it to why col-md-9 would help?

I think I am not good enough in html or css to explain this actually. I tried to understand the actual problem, compared the article page with the other pages and added col-md-9 manually to the html (because that is the main difference between the article page and e.g. the changelog page). And it worked. See
image

@mrcaseb
Copy link
Contributor Author

mrcaseb commented Jun 2, 2022

The article pages on my websites are fixed, thanks @hadley!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
articles ✍️ reprex needs a minimal reproducible example
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants