Skip to content

Commit

Permalink
Merge pull request #10712 from quarto-dev/listing/categories-links
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv authored Sep 9, 2024
2 parents f0fcab9 + 826a133 commit cf0b7d0
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions news/changelog-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ All changes included in 1.6:

- ([#10268](https://github.com/quarto-dev/quarto-cli/issues/10268)]): `quarto create` supports opening project in Positron, in addition to VS Code and RStudio IDE.

## Quarto Blog

- ([#10710](https://github.com/quarto-dev/quarto-cli/issues/10710)): Fix an issue with categorie badges as links in the blog post header.

## Engines

### `julia`
Expand Down
5 changes: 4 additions & 1 deletion src/resources/formats/html/quarto.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
}

async function findAndActivateCategories() {
const currentPagePath = offsetAbsoluteUrl(window.location.href);
// Categories search with listing only use path without query
const currentPagePath = offsetAbsoluteUrl(
window.location.origin + window.location.pathname
);
const response = await fetch(offsetRelativeUrl("listings.json"));
if (response.status == 200) {
return response.json().then(function (listingPaths) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ This is the first post in a Quarto blog. Welcome!

![](thumbnail.jpg)

## About image listing {#img-lst}

Since this post doesn't specify an explicit `image`, the first image in the post will be used in the listing page of posts.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getUrl } from "../src/utils.js";

test('List.js is correctly patch to allow searching with lowercase and uppercase',
async ({ page }) => {
await page.goto(getUrl('blog/listing-search/_site/'));
await page.goto(getUrl('blog/simple-blog/_site/'));
await page.getByPlaceholder('Filter').click();
await page.getByPlaceholder('Filter').fill('Code');
await page.getByPlaceholder('Filter').press('Enter');
Expand All @@ -21,3 +21,14 @@ test('List.js is correctly patch to allow searching with lowercase and uppercase
await expect(page.getByRole('link', { name: 'Post With Code' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeHidden();
});

test('Categories link are clickable', async ({ page }) => {
await page.goto(getUrl('blog/simple-blog/_site/posts/welcome/'));
await page.locator('div').filter({ hasText: /^news$/ }).click();
await expect(page).toHaveURL(/_site\/index\.html#category=news$/);
await expect(page.locator('div.category[data-category="news"]')).toHaveClass(/active/);
await page.goto(getUrl('blog/simple-blog/_site/posts/welcome/#img-lst'));
await page.locator('div').filter({ hasText: /^news$/ }).click();
await expect(page).toHaveURL(/_site\/index\.html#category=news$/);
await expect(page.locator('div.category[data-category="news"]')).toHaveClass(/active/);
});

0 comments on commit cf0b7d0

Please sign in to comment.