Skip to content

Commit

Permalink
Sort articles alphabetically by file name (#2254)
Browse files Browse the repository at this point in the history
* Add failing test

* Change the order

* Add NEWS bullet
  • Loading branch information
jennybc authored May 8, 2023
1 parent fd8a184 commit 7b810a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pkgdown (development version)

* The article index now sorts vignettes and non-vignette articles alphabetically by their filename (literally, their `basename()`), by default (@jennybc, #2253).

# pkgdown 2.0.7

* Fix topic match selection when there is an unmatched selection followed by a matched selection (@bundfussr, #2234)
Expand Down
3 changes: 2 additions & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,15 @@ package_vignettes <- function(path = ".") {
)
check_unique_article_paths(file_in, file_out)

tibble::tibble(
out <- tibble::tibble(
name = path_ext_remove(vig_path),
file_in = file_in,
file_out = file_out,
title = title,
description = desc,
depth = dir_depth(file_out)
)
out[order(basename(out$file_out)), ]
}

find_template_config <- function(package, bs_version = NULL) {
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ test_that("package_vignettes() detects conflicts in final article paths", {
expect_error(package_vignettes(dir))
})

test_that("package_vignettes() sorts articles alphabetically by file name", {
pkg <- local_pkgdown_site(test_path("assets/articles"))
expect_equal(
order(basename(pkg$vignettes$file_out)),
seq_len(nrow(pkg$vignettes))
)
})

# titles ------------------------------------------------------------------

Expand Down

0 comments on commit 7b810a7

Please sign in to comment.