Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listing - link activation for categories should work on any window.lo… #10712

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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/);
});
Loading