quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.73k stars 305 forks source link

sidebar: contents: auto incorrect ordering #9127

Open aronatkins opened 5 months ago

aronatkins commented 5 months ago

Bug description

Given a project with listings having directory structure and titles derived from dates, contents: auto incorrectly orders the sidebar contents.

Steps to reproduce

Given a directory structure:

_quarto.yml
index.qmd
things/2024-03-04/index.qmd
things/2024-03-11/index.qmd
things/2024-03-18/index.qmd

The quarto.yml

project:
  type: website

website:
  title: "things"
  sidebar:
    contents: auto

The index.qmd

---
title: all things
listing:
  contents: "./things/*/index.qmd"
  sort: "title asc"
  type: table
---

Each of the things/YYYY-MM-DD/index.qmd files looks like:

---
title: Thing 2024-03-04
---

Expected behavior

The sidebar listing order should show a reversed version of the embedded listing table, where titles are listed in ascending order.

Actual behavior

The sidebar listing order is in some other (arbitrary?) order.

image

Your environment

Tested with Quarto 1.4.549 and Quarto 1.5.24.

Quarto check output

Quarto 1.5.24
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.24
      Path: /Users/aron/Downloads/quarto-1.5.24-macos/bin

[✓] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/aron/Library/TinyTeX/bin/universal-darwin
      Version: 2022

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.2
      Path: /usr/local/opt/python@3.12/bin/python3.12
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
      knitr: 1.45
      rmarkdown: 2.25

[✓] Checking Knitr engine render......OK
mcanouil commented 5 months ago

I noticed something a bit similar in another setup using a YAML file to set the content. I can't figure out what's the order logic.

EDIT: using the above setup, you get similar behaviour with:

project:
  type: website

website:
  title: "things"
  sidebar:
    contents: things

FYI, the documentation states that "auto" means alphabetical order.

https://quarto.org/docs/websites/website-navigation.html#auto-generation

aronatkins commented 4 weeks ago

Is this because the filenames for all entries are things/2024-06-11/index.md and the sorting is using the "basename" to order?

https://github.com/quarto-dev/quarto-cli/blob/fe989e5468f2a5e0545a0db441a771a74f9e3098/src/project/types/website/website-sidebar-auto.ts#L314-L316

The basename of every file is index.md, which means that the sort is ambiguous.

When a sidebar is define by a glob like things/*/index.md, should the entire (relative) filename should be considered when sorting?