rstudio / leaflet

R Interface to Leaflet Maps
http://rstudio.github.io/leaflet/
Other
805 stars 508 forks source link

docs: Convert website to use `{pkgdown}` #902

Closed olivroy closed 7 months ago

olivroy commented 7 months ago

Now hosted at https://rstudio.github.io/leaflet

I think some of the information is a bit dated, but will not pursue further if there is no interest.

For deployment, you need to setup gh pages with usethis::use_pkgdown_github_pages().

Everything renders! Polishing probably necessary in a potential follow-up

But having the function reference online, search function seems like an improvement to me? Capture d’écran, le 2024-02-16 à 9 24 39 a m

Outstanding work if you decide to proceed:

On my side:

On your side:

schloerke commented 7 months ago

Thank you @olivroy !!

Could extra requests:

olivroy commented 7 months ago

@schloerke Would you want me to delete the old docs directory, or leaving it as docs_old/ is okay for now?

schloerke commented 7 months ago

@schloerke Would you want me to delete the old docs directory, or leaving it as docs_old/ is okay for now?

The geojson files in docs_old/json need to be available to the files. Maybe we put the data files in the pkgdown/assets folder and add the assets folder in the pkgdown config? (And also move the _pkgdown.yml file to pkgdown/_pkgdown.yml, similar to https://github.com/rstudio/plumber/blob/56a69494cf15c3c3ca0831a86a91ba033337206a/pkgdown/_pkgdown.yml#L9 )

By having the files as assets, they are available on the website and users can see the full url. In the past, we've had comments that the files do not exist on user's local machines when copying the example to run. So I'd like to keep the URL behavior if possible.

I do not see any other files that I would keep in docs_old/. Let's remove it? Thank you!

schloerke commented 7 months ago

Two comments then I think we're good to go!


Can we move the json files in pkgdown/assets/FILE to pkgdown/assets/json/FILE? This will keep the existing urls like https://rstudio.github.io/leaflet/json/us-states.geojson working.


We need to add redirect HTML files from the previous vignette locations to the new locations. In addition, I'd like to maintain the hash being used. (**working on getting an example file / instructions)

schloerke commented 7 months ago

We should add files with the content of: (untested)

<!DOCTYPE html>
<html>
  <body>
    <h1>VIGTITLE</h1>
    Please find the article at its <a href="articles/ARTICLE">new location</a>
<script>
  window.location.href = "articles/ARTICLE" + window.location.hash;
</script>
  </body>
</html>

Where VIGTITLE is the article title and ARTICLE is the file name.

Within pkgdown/assets, we need an HTML redirect file (named ARTICLE) for every past article (except for ./):

ARTICLE - VIGTITLE:

olivroy commented 7 months ago

I tested the pkgdown approach for redirects locally, but ideally, we'd overwrite the site now, and move to dev mode later? I tested this with servr locally, and changed the URL manually in my browser, and it works well!

https://pkgdown.r-lib.org/reference/build_site.html#redirects

schloerke commented 7 months ago

Yes! (TIL, again!)

The previous website didn't really have headers to click on to set the hash. So the pkgdown redirects will work great. Thank you

schloerke commented 7 months ago

Thank you @olivroy !

olivroy commented 7 months ago

Thanks for the prompt review! (I would have forgotten the redirects !)

I will send a follow-up early next week to address outstanding issues! And will test outstanding issues, reorder vignettes etc. maybe use the json approach and move other shapefiles / resources to pkgdown/assets to read from the website as much as possible, add back the copywright license in the bottom. The "leaflet" R package is copyright © 2014-2023 Posit Software, PBC. The Leaflet JavaScript library is © 2010–2023 Vladimir Agafonkin, 2010–2011 CloudMade. Maps © OpenStreetMap contributors unless otherwise noted.

to make the reproducibility of examples easier to do for users. internal links in the articles. ( I didn't want to read all the content in the context of this PR)

schloerke commented 7 months ago

( I didn't want to read the content in the context of this PR)

I appreciate it.

I look forward to the followup next week. I'll try to have the PR merged (**waiting on team approval) later today.

schloerke commented 7 months ago

Thank you @olivroy !!