File tree Expand file tree Collapse file tree 9 files changed +84
-4
lines changed
src/quarto-core/attribution
tests/docs/smoke-all/2024/05/06/9524 Expand file tree Collapse file tree 9 files changed +84
-4
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ All changes included in 1.5:
6363- ([ #8977 ] ( https://github.com/quarto-dev/quarto-cli/issues/8977 ) ): Don't decorate about links within external link icons.
6464- ([ #8986 ] ( https://github.com/quarto-dev/quarto-cli/issues/8986 ) ): Search: only build subfuse index when it's safe to do so.
6565- ([ #9356 ] ( https://github.com/quarto-dev/quarto-cli/issues/9356 ) ): Don't process column classes for figures inside the About divs.
66+ - ([ #9524 ] ( https://github.com/quarto-dev/quarto-cli/issues/9524 ) ): Fix canonical URL generation for website pages.
6667- ([ #9781 ] ( https://github.com/quarto-dev/quarto-cli/issues/9781 ) ): Correctly hide elements from click event in collapsed margin sidebar.
6768- Sidebar navigation item now correctly supports ` rel ` attribute.
6869- ` target ` attribute for sidebar navigation items is now correctly inserted with HTML escapes.
Original file line number Diff line number Diff line change @@ -447,14 +447,18 @@ export function synthesizeCitationUrl(
447447 offset ?: string ,
448448) {
449449 const siteMeta = metadata [ kWebsite ] as Metadata | undefined ;
450- const baseUrl = siteMeta ?. [ kSiteUrl ] as string ;
450+ let baseUrl = siteMeta ?. [ kSiteUrl ] as string ;
451451
452452 if ( baseUrl && outputFile && offset ) {
453+ baseUrl = baseUrl . replace ( / \/ $ / , "" ) ;
453454 const rootDir = normalizePath ( join ( dirname ( input ) , offset ) ) ;
454455 if ( outputFile === "index.html" ) {
455- return `${ baseUrl } /${
456- pathWithForwardSlashes ( relative ( rootDir , dirname ( input ) ) )
457- } `;
456+ const part = pathWithForwardSlashes ( relative ( rootDir , dirname ( input ) ) ) ;
457+ if ( part . length === 0 ) {
458+ return `${ baseUrl } /` ;
459+ } else {
460+ return `${ baseUrl } /${ part } /` ;
461+ }
458462 } else {
459463 const relativePath = relative (
460464 rootDir ,
Original file line number Diff line number Diff line change 1+ /.quarto /
Original file line number Diff line number Diff line change 1+ project :
2+ type : website
3+
4+ website :
5+ site-url : https://index.html.com/
6+ title : " Quarto 9524"
7+ navbar :
8+ left :
9+ - href : index.qmd
10+ text : Home
11+ - about/index.qmd
12+ - about/test/something.qmd
13+ - root-page.index.qmd
14+
15+ format :
16+ html :
17+ canonical-url : true
Original file line number Diff line number Diff line change 1+ ---
2+ title : " Untitled"
3+ _quarto :
4+ tests :
5+ html :
6+ ensureHtmlElements :
7+ - ['link[rel="canonical"][href="https://index.html.com/about/file.html"]']
8+ - []
9+ ---
10+
11+ A non ` index ` file at the root of a subdirectory.
Original file line number Diff line number Diff line change 1+ ---
2+ title : " About"
3+ _quarto :
4+ tests :
5+ html :
6+ ensureHtmlElements :
7+ - ['link[rel="canonical"][href="https://index.html.com/about/"]']
8+ - []
9+ ---
10+
11+ About this site
Original file line number Diff line number Diff line change 1+ ---
2+ title : " Untitled"
3+ _quarto :
4+ tests :
5+ html :
6+ ensureHtmlElements :
7+ - ['link[rel="canonical"][href="https://index.html.com/about/test/something.html"]']
8+ - []
9+ ---
10+
11+ Another file inside a nested directory.
Original file line number Diff line number Diff line change 1+ ---
2+ title : " Quarto 9524"
3+ _quarto :
4+ tests :
5+ html :
6+ ensureHtmlElements :
7+ - ['link[rel="canonical"][href="https://index.html.com/"]']
8+ - []
9+ ---
10+
11+ This is a Quarto website.
12+
13+ To learn more about Quarto websites visit < https://quarto.org/docs/websites > .
Original file line number Diff line number Diff line change 1+ ---
2+ title : root page
3+ _quarto :
4+ tests :
5+ html :
6+ ensureHtmlElements :
7+ - ['link[rel="canonical"][href="https://index.html.com/root-page.index.html"]']
8+ - []
9+ ---
10+
11+ Root page with "index." pattern.
You can’t perform that action at this time.
0 commit comments