From 134ea9bbd1af47c18beae1f45b59a33bbeb3b3ef Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 4 Sep 2024 13:49:31 +0200 Subject: [PATCH 1/3] listing - link activation for categories should work on any window.location It requires to strip any query search or hash part from the URL before comparing it to the link retrieved in listings' items. --- src/resources/formats/html/quarto.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/resources/formats/html/quarto.js b/src/resources/formats/html/quarto.js index 39e6869927..3c24c295ff 100644 --- a/src/resources/formats/html/quarto.js +++ b/src/resources/formats/html/quarto.js @@ -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) { From 93db833609359da7a90bd562d1ebf13cd3ddb6bc Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 5 Sep 2024 20:34:08 +0200 Subject: [PATCH 2/3] Add to changelog [skip ci] --- news/changelog-1.6.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/news/changelog-1.6.md b/news/changelog-1.6.md index f1756e6d1c..ed389e9758 100644 --- a/news/changelog-1.6.md +++ b/news/changelog-1.6.md @@ -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` From 826a1335603cafe304acf417bb3001eddb62d8ae Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 9 Sep 2024 11:55:05 +0200 Subject: [PATCH 3/3] New test for blog categories click - Add a new playwright test for blog categories click - Refactor by using same project than the other tests for blog. --- .../{listing-search => simple-blog}/.gitignore | 0 .../{listing-search => simple-blog}/_quarto.yml | 0 .../blog/{listing-search => simple-blog}/index.qmd | 0 .../posts/_metadata.yml | 0 .../posts/post-with-code/image.jpg | Bin .../posts/post-with-code/index.qmd | 0 .../posts/welcome/index.qmd | 2 ++ .../posts/welcome/thumbnail.jpg | Bin ...ing-search.spec.ts => blog-simple-blog.spec.ts} | 13 ++++++++++++- 9 files changed, 14 insertions(+), 1 deletion(-) rename tests/docs/playwright/blog/{listing-search => simple-blog}/.gitignore (100%) rename tests/docs/playwright/blog/{listing-search => simple-blog}/_quarto.yml (100%) rename tests/docs/playwright/blog/{listing-search => simple-blog}/index.qmd (100%) rename tests/docs/playwright/blog/{listing-search => simple-blog}/posts/_metadata.yml (100%) rename tests/docs/playwright/blog/{listing-search => simple-blog}/posts/post-with-code/image.jpg (100%) rename tests/docs/playwright/blog/{listing-search => simple-blog}/posts/post-with-code/index.qmd (100%) rename tests/docs/playwright/blog/{listing-search => simple-blog}/posts/welcome/index.qmd (89%) rename tests/docs/playwright/blog/{listing-search => simple-blog}/posts/welcome/thumbnail.jpg (100%) rename tests/integration/playwright/tests/{blog-listing-search.spec.ts => blog-simple-blog.spec.ts} (62%) diff --git a/tests/docs/playwright/blog/listing-search/.gitignore b/tests/docs/playwright/blog/simple-blog/.gitignore similarity index 100% rename from tests/docs/playwright/blog/listing-search/.gitignore rename to tests/docs/playwright/blog/simple-blog/.gitignore diff --git a/tests/docs/playwright/blog/listing-search/_quarto.yml b/tests/docs/playwright/blog/simple-blog/_quarto.yml similarity index 100% rename from tests/docs/playwright/blog/listing-search/_quarto.yml rename to tests/docs/playwright/blog/simple-blog/_quarto.yml diff --git a/tests/docs/playwright/blog/listing-search/index.qmd b/tests/docs/playwright/blog/simple-blog/index.qmd similarity index 100% rename from tests/docs/playwright/blog/listing-search/index.qmd rename to tests/docs/playwright/blog/simple-blog/index.qmd diff --git a/tests/docs/playwright/blog/listing-search/posts/_metadata.yml b/tests/docs/playwright/blog/simple-blog/posts/_metadata.yml similarity index 100% rename from tests/docs/playwright/blog/listing-search/posts/_metadata.yml rename to tests/docs/playwright/blog/simple-blog/posts/_metadata.yml diff --git a/tests/docs/playwright/blog/listing-search/posts/post-with-code/image.jpg b/tests/docs/playwright/blog/simple-blog/posts/post-with-code/image.jpg similarity index 100% rename from tests/docs/playwright/blog/listing-search/posts/post-with-code/image.jpg rename to tests/docs/playwright/blog/simple-blog/posts/post-with-code/image.jpg diff --git a/tests/docs/playwright/blog/listing-search/posts/post-with-code/index.qmd b/tests/docs/playwright/blog/simple-blog/posts/post-with-code/index.qmd similarity index 100% rename from tests/docs/playwright/blog/listing-search/posts/post-with-code/index.qmd rename to tests/docs/playwright/blog/simple-blog/posts/post-with-code/index.qmd diff --git a/tests/docs/playwright/blog/listing-search/posts/welcome/index.qmd b/tests/docs/playwright/blog/simple-blog/posts/welcome/index.qmd similarity index 89% rename from tests/docs/playwright/blog/listing-search/posts/welcome/index.qmd rename to tests/docs/playwright/blog/simple-blog/posts/welcome/index.qmd index 597353245e..b8cb583f96 100644 --- a/tests/docs/playwright/blog/listing-search/posts/welcome/index.qmd +++ b/tests/docs/playwright/blog/simple-blog/posts/welcome/index.qmd @@ -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. diff --git a/tests/docs/playwright/blog/listing-search/posts/welcome/thumbnail.jpg b/tests/docs/playwright/blog/simple-blog/posts/welcome/thumbnail.jpg similarity index 100% rename from tests/docs/playwright/blog/listing-search/posts/welcome/thumbnail.jpg rename to tests/docs/playwright/blog/simple-blog/posts/welcome/thumbnail.jpg diff --git a/tests/integration/playwright/tests/blog-listing-search.spec.ts b/tests/integration/playwright/tests/blog-simple-blog.spec.ts similarity index 62% rename from tests/integration/playwright/tests/blog-listing-search.spec.ts rename to tests/integration/playwright/tests/blog-simple-blog.spec.ts index 86c4d18184..2de55c2858 100644 --- a/tests/integration/playwright/tests/blog-listing-search.spec.ts +++ b/tests/integration/playwright/tests/blog-simple-blog.spec.ts @@ -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'); @@ -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/); +}); \ No newline at end of file