Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
40234f7
feat: allow to customise pagination options for listings
mcanouil Jul 24, 2025
3688a95
fix: make names consistent
mcanouil Jul 24, 2025
56b7363
fix: ensure pagination options are defined before rendering
mcanouil Jan 14, 2026
e4b0a2f
fix: improve pagination descriptions for clarity
mcanouil Jan 14, 2026
cd78fd6
fix: define PaginationOptions type for improved type safety
mcanouil Jan 14, 2026
39c9c7c
test: add pagination tests for listings
mcanouil Jan 14, 2026
03d34cb
fix: emit list.js pagination keys and check option values
mcanouil Nov 3, 2026
d2ab1bd
feat: label listing pagination for assistive technology
mcanouil Nov 3, 2026
1d63a81
test: check listing pagination links, labels and keyboard
mcanouil Nov 3, 2026
c22fcac
chore: regenerate schema artifacts
mcanouil Nov 3, 2026
5d8c4e9
docs: add changelog entry for listing pagination
mcanouil Nov 3, 2026
d9f994a
docs: describe pagination labels for translators and move changelog e…
mcanouil Nov 3, 2026
0b35493
docs: clarify translator comment for the pagination landmark label
mcanouil Nov 3, 2026
4c6dadf
style: keep the existing fs import layout in the listing reader
mcanouil Nov 3, 2026
371d3f2
fix: drop the misleading zero default from per-side outer-window options
mcanouil Nov 3, 2026
7ce3c69
test: check pagination accessibility on a single-listing page
mcanouil Nov 3, 2026
505b2ff
fix: name the listing pagination landmark with a noun
mcanouil Nov 3, 2026
2a4c0c3
fix: add the pagination language keys to the format-language schema
mcanouil Nov 3, 2026
38a4a9d
test: assert pagination link names instead of ARIA snapshots
mcanouil Nov 3, 2026
5e9b2ea
fix: accept only numbers for listing pagination options
mcanouil Nov 3, 2026
eab9f5a
test: validate listing pagination options against the schema
mcanouil Nov 3, 2026
9837890
refactor: find the pagination nav through the listing element
mcanouil Nov 3, 2026
fb61d6e
test: render the pagination warning from its own fixture
mcanouil Nov 3, 2026
6552023
docs: split the listing pagination changelog entry
mcanouil Nov 3, 2026
b477ab8
test: move the pagination warning fixture out of the listings project
mcanouil Nov 3, 2026
224f347
fix: keep the page number in pagination link names
mcanouil Nov 3, 2026
e09ac81
chore: keep the esbuild analysis cache as on main
mcanouil Nov 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions news/changelog-1.12.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
All changes included in 1.12:

## Accessibility

- ([#13126](https://github.com/quarto-dev/quarto-cli/pull/13126)): Label the pagination control of website listings for screen readers: the control has a localised name, each page link is named "Page n", the current page is marked, and the "..." gaps are no longer focusable. (author: @mcanouil)

## Formats

### `pdf`
Expand All @@ -11,6 +15,12 @@ All changes included in 1.12:
- ([#15168](https://github.com/quarto-dev/quarto-cli/issues/15168)): Fix definitions, examples and exercises being set in italics in Typst output with the default `theorem-appearance: simple`. Their body is now upright, as in LaTeX output, while theorems, lemmas, corollaries, propositions and conjectures keep an italic body. (author: @mcanouil)
- ([#15251](https://github.com/quarto-dev/quarto-cli/pull/15251)): Fix algorithm blocks (`#alg-`) being set in italics with `theorem-appearance: simple` and using the colours of theorems with `theorem-appearance: fancy`. They now look like definitions, examples and exercises. (author: @mcanouil)

## Projects

### Websites

- ([#13126](https://github.com/quarto-dev/quarto-cli/pull/13126)): Add `pagination` options to listings to set how many page links are shown (`inner-window`, `outer-window`, `outer-window-left`, `outer-window-right`). (author: @mcanouil)

## Commands

### `quarto preview`
Expand Down
4 changes: 4 additions & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ export const kListingPageMinutesCompact = "listing-page-minutes-compact";
export const kListingPageWords = "listing-page-words";
export const kListingPageCategoryAll = "listing-page-category-all";
export const kListingPageNoMatches = "listing-page-no-matches";
export const kListingPagePagination = "listing-page-pagination";
export const kListingPageNumber = "listing-page-number";
export const kNotebookPreviewDownload = "notebook-preview-download";
export const kNotebookPreviewDownloadSrc = "notebook-preview-download-src";
export const kNotebookPreviewBack = "notebook-preview-back";
Expand Down Expand Up @@ -524,6 +526,8 @@ export const kLanguageDefaultsKeys = [
kListingPageWords,
kListingPageCategoryAll,
kListingPageNoMatches,
kListingPagePagination,
kListingPageNumber,
kTitleBlockAuthorSingle,
kTitleBlockAuthorPlural,
kTitleBlockAffiliationSingle,
Expand Down
4 changes: 4 additions & 0 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ import {
kListingPageFilter,
kListingPageMinutesCompact,
kListingPageNoMatches,
kListingPageNumber,
kListingPageOrderBy,
kListingPageOrderByDateAsc,
kListingPageOrderByDateDesc,
kListingPageOrderByDefault,
kListingPageOrderByNumberAsc,
kListingPageOrderByNumberDesc,
kListingPagePagination,
kListingPageWords,
kListings,
kManuscriptMecaBundle,
Expand Down Expand Up @@ -770,6 +772,8 @@ export interface FormatLanguage {
[kListingPageWords]?: string;
[kListingPageCategoryAll]?: string;
[kListingPageNoMatches]?: string;
[kListingPagePagination]?: string;
[kListingPageNumber]?: string;
[kNotebookPreviewDownload]?: string;
[kNotebookPreviewDownloadSrc]?: string;
[kNotebookPreviewBack]?: string;
Expand Down
50 changes: 50 additions & 0 deletions src/project/types/website/listing/website-listing-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ import {
kImageLazyLoading,
kImagePlaceholder,
kInclude,
kInnerWindow,
kLeftOuterWindow,
kListing,
kMaxDescLength,
kOuterWindow,
kPageSize,
kPaginationOptions,
kRightOuterWindow,
kSortAsc,
kSortDesc,
kSortUi,
Expand All @@ -86,6 +91,7 @@ import {
ListingSharedOptions,
ListingSort,
ListingType,
PaginationOptions,
PreviewImage,
renderedContentReader,
} from "./website-listing-shared.ts";
Expand Down Expand Up @@ -151,6 +157,45 @@ const kDefaultFields = [
kFieldDescription,
];

const kPaginationMinimums: Record<keyof PaginationOptions, number> = {
[kInnerWindow]: 1,
[kOuterWindow]: 0,
[kLeftOuterWindow]: 0,
[kRightOuterWindow]: 0,
};

// Keeps the pagination options that are whole numbers at or above their
// minimum; warns about and drops the others.
export function resolvePaginationOptions(
listingId: string,
raw: unknown,
): PaginationOptions | undefined {
if (raw === undefined) {
return undefined;
}
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
warning(
`Listing '${listingId}': pagination must be an object with inner-window, outer-window, outer-window-left or outer-window-right, got '${raw}'. The option is ignored.`,
);
return undefined;
}
const resolved: PaginationOptions = {};
for (const [key, min] of Object.entries(kPaginationMinimums)) {
const value = (raw as Record<string, unknown>)[key];
if (value === undefined) {
continue;
}
if (typeof value === "number" && Number.isInteger(value) && value >= min) {
resolved[key as keyof PaginationOptions] = value;
} else {
warning(
`Listing '${listingId}': pagination option '${key}' must be a whole number of ${min} or more, got '${value}'. The option is ignored.`,
);
}
}
return Object.keys(resolved).length > 0 ? resolved : undefined;
}

const defaultFieldDisplayNames = (format: Format) => {
return {
[kFieldImage]: " ",
Expand Down Expand Up @@ -671,6 +716,11 @@ function hydrateListing(
...listing,
});

listingHydrated[kPaginationOptions] = resolvePaginationOptions(
listingHydrated.id,
listing[kPaginationOptions],
);

// Apply a default sort if the title field is present and the sources contain documents
const sort: ListingSort[] | undefined = hydratedFields.includes(kFieldTitle)
? [
Expand Down
24 changes: 24 additions & 0 deletions src/project/types/website/listing/website-listing-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ export const kFieldFilter = "field-filter";
// The number of rows to display per page
export const kPageSize = "page-size";

// Pagination options
export const kPaginationOptions = "pagination";

// How many pages should be visible on each side of the current page
export const kInnerWindow = "inner-window";

// How many pages should be visible at the beginning and at the end of the pagination
export const kOuterWindow = "outer-window";

// Same as outer-window but for the beginning only
export const kLeftOuterWindow = "outer-window-left";

// Same as outer-window but for the end only
export const kRightOuterWindow = "outer-window-right";

// Pagination options interface
export interface PaginationOptions {
[kInnerWindow]?: number;
[kOuterWindow]?: number;
[kLeftOuterWindow]?: number;
[kRightOuterWindow]?: number;
}

// The maximum number of items to include
export const kMaxItems = "max-items";

Expand Down Expand Up @@ -169,6 +192,7 @@ export interface Listing extends ListingDehydrated {
[kFieldFilter]: string[];
[kFieldRequired]: string[];
[kPageSize]: number;
[kPaginationOptions]?: PaginationOptions;
[kMaxItems]?: number;
[kFilterUi]: boolean;
[kSortUi]: boolean;
Expand Down
23 changes: 22 additions & 1 deletion src/project/types/website/listing/website-listing-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ import {
kFieldSort,
kFieldTypes,
kImageHeight,
kInnerWindow,
kLeftOuterWindow,
kMaxDescLength,
kMaxItems,
kOuterWindow,
kPageSize,
kPaginationOptions,
kRightOuterWindow,
kSortAsc,
kSortDesc,
Listing,
Expand Down Expand Up @@ -524,13 +529,29 @@ export function templateJsScript(
itemCount: number,
) {
const pageSize = listing[kPageSize] as number || 50;
const listingPaginationOptions = listing[kPaginationOptions] || {};

// If columns are present, factor that in
const columns = listing[kFields] as string[] || [];

// list.js reads `left || outerWindow`, so a side of 0 cannot override
// outerWindow; both sides are resolved here and outerWindow is never emitted.
const outerWindow = listingPaginationOptions[kOuterWindow];
const left = listingPaginationOptions[kLeftOuterWindow] ?? outerWindow;
const right = listingPaginationOptions[kRightOuterWindow] ?? outerWindow;
const innerWindow = listingPaginationOptions[kInnerWindow];
const paginationOptions = [
innerWindow !== undefined ? `innerWindow: ${innerWindow}` : "",
left !== undefined ? `left: ${left}` : "",
right !== undefined ? `right: ${right}` : "",
"item: \"<li class='page-item'><a class='page page-link' href='#'></a></li>\"",
]
.filter((v) => v !== "")
.join(", ");

const pageOptions = itemCount > pageSize
? `${pageSize ? `page: ${pageSize}` : ""},
pagination: { item: "<li class='page-item'><a class='page page-link' href='#'></a></li>" },`
pagination: { ${paginationOptions} },`
: "";

const filterOptions = `searchColumns: [${
Expand Down
41 changes: 38 additions & 3 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10604,6 +10604,8 @@ var init_yaml_intelligence_resources = __esm({
"listing-page-minutes-compact": "string",
"listing-page-category-all": "string",
"listing-page-no-matches": "string",
"listing-page-pagination": "string",
"listing-page-number": "string",
"listing-page-words": "string",
"listing-page-filter": "string",
draft: "string"
Expand Down Expand Up @@ -10788,6 +10790,35 @@ var init_yaml_intelligence_resources = __esm({
long: "Display item categories from this listing in the margin of the page.\n\n - `numbered`: Category list with number of items\n - `unnumbered`: Category list\n - `cloud`: Word cloud style categories\n"
}
},
pagination: {
object: {
closed: true,
properties: {
"inner-window": {
number: {
description: "The number of page links to show on each side of the current page (whole number, 1 or more). Applies only when the listing has more items than `page-size`.",
default: 2
}
},
"outer-window": {
number: {
description: "The number of page links to show at the start and at the end of the pagination control (whole number, 0 or more). Applies only when the listing has more items than `page-size`.",
default: 0
}
},
"outer-window-left": {
number: {
description: "The number of page links to show at the start of the pagination control, overriding `outer-window` for that side (whole number, 0 or more). Applies only when the listing has more items than `page-size`."
}
},
"outer-window-right": {
number: {
description: "The number of page links to show at the end of the pagination control, overriding `outer-window` for that side (whole number, 0 or more). Applies only when the listing has more items than `page-size`."
}
}
}
}
},
feed: {
anyOf: [
"boolean",
Expand Down Expand Up @@ -22703,6 +22734,10 @@ var init_yaml_intelligence_resources = __esm({
short: "Display item categories from this listing in the margin of the\npage.",
long: "Display item categories from this listing in the margin of the\npage."
},
"The number of page links to show on each side of the current page\n(whole number, 1 or more). Applies only when the listing has more items\nthan <code>page-size</code>.",
"The number of page links to show at the start and at the end of the\npagination control (whole number, 0 or more). Applies only when the\nlisting has more items than <code>page-size</code>.",
"The number of page links to show at the start of the pagination\ncontrol, overriding <code>outer-window</code> for that side (whole\nnumber, 0 or more). Applies only when the listing has more items than\n<code>page-size</code>.",
"The number of page links to show at the end of the pagination\ncontrol, overriding <code>outer-window</code> for that side (whole\nnumber, 0 or more). Applies only when the listing has more items than\n<code>page-size</code>.",
"Enables an RSS feed for the listing.",
"The number of items to include in your feed. Defaults to 20.",
{
Expand Down Expand Up @@ -25824,12 +25859,12 @@ var init_yaml_intelligence_resources = __esm({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 221299,
_internalId: 221314,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 221291,
_internalId: 221306,
type: "enum",
enum: [
"png",
Expand All @@ -25845,7 +25880,7 @@ var init_yaml_intelligence_resources = __esm({
exhaustiveCompletions: true
},
theme: {
_internalId: 221298,
_internalId: 221313,
type: "anyOf",
anyOf: [
{
Expand Down

Large diffs are not rendered by default.

41 changes: 38 additions & 3 deletions src/resources/editor/tools/yaml/web-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading