quarto-dev / quarto-cli

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

Using sort-ui sorting by "Title" sorts by file name (Quarto Website) #10398

Open sverchkov opened 1 month ago

sverchkov commented 1 month ago

Bug description

Given a listing generated by glob-matching files, and sort-ui enabled on the listing, using the UI to sort by "title" sorts the listing by file names instead.

Steps to reproduce

Initiate a quarto website project with the following directory structure:

index.qmd
pages/
- p1.qmd
- p2.qmd
- p3.qmd

With the following file contents: index.qmd:

---
title: "quarto-sorting-repr"

listing:
    sort-ui: true
    sort: title
    fields: [date, title]
    contents:
        - pages/**.qmd
---

pages/p1.qmd:

---
title: C
---

File p1

pages/p2.qmd:

---
title: A
---

File p2

pages/p3.qmd:

---
title: B
---

File p3

Build the website and navigate to the main page. In the sorting interface, select "Title"

Expected behavior

The listing should be ordered by the titles of each document, that is A, B, C

Actual behavior

The listing order becomes C, A, B.

This seems to correspond to file name order (p1.qmd, p2.qmd, p3.qmd)

Your environment

IDE: VSCode Version: 1.91.1 (user setup) Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:06:49.809Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.19045

Quarto check output

Quarto 1.4.550
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.550
      Path: /opt/quarto/bin

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

[✓] Checking LaTeX....................OK
      Tex:  (not detected)

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.4 (Conda)
      Path: /home/yuriy/miniconda3/bin/python
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with conda install jupyter

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/
mcanouil commented 1 month ago

I cannot reproduce.

image

Since your example is not fully reproducible, please share a Git repository. Also, current stable version is 1.5, please upgrade your Quarto version.

sverchkov commented 1 month ago

Sure thing! I've updated to 1.5 and get the same behavior.

Quarto check:

Quarto 1.5.55
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.55
      Path: /opt/quarto/bin

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

[✓] Checking LaTeX....................OK
      Tex:  (not detected)

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

[✓] Checking Python 3 installation....OK
      Version: 3.10.12
      Path: /bin/python3
      Jupyter: (None)

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

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

Repo: https://github.com/sverchkov/quarto-sorting-repr Deployed at https://sverchkov.github.io/quarto-sorting-repr/

Note that the sort order works as expected. It is the sort-ui behavior that is unexpected.

sverchkov commented 1 month ago

quarto-sorting

Clip of the behavior

mcanouil commented 1 month ago

It seems the filter by "title" actually uses the filename.

The issue is the EJS listing.

It seams the URL path is used, while moving the target listing-<id> closer to the real target solves the issue.

<h3 class="no-anchor"><a href="<%- item.path %>" class="listing-title no-external"><%= item.title %></a></h3>

Alternatively, the JavaScript script could be updated but seems more complex and right now I don't know exactly which part:

Note that this also has an impact on other tooling and fields: