Repository navigation
feat(site): load the musician pages as full documents, ready for a separate build - #491
Merged
Merged
Conversation
…parate build The home, the tools, the extension's pages and the website privacy notice will be served by a separate build at the same addresses, while the docs stay here. VitePress treats every same-origin link as its own route, so once a page moves, a click from a docs page would render this site's old copy, or its 404 for a page it never built. The router hook now hands those paths to the browser as a full load. It changes no page's HTML: today a full load serves the same VitePress page, so the whole list ships at once and no later move needs a docs deploy. Hash links on a page stay client-side, and the first load of a page this build serves is never reloaded. The build also writes sitemap-docs.xml, sitemap.xml minus those pages, for a sitemap index to list later; sitemap.xml stays as it is. The redirect checker accepts a musician page as a target even once this build stops emitting it, so the stubs that point at the home keep building after its copy is deleted.
…, and test their full loads VitePress lowercases a path and treats foo, foo/ and foo/index as one page, so a link written /extension or /Metronome would still have rendered this build's copy client-side. The router decision now matches the page VitePress would render; the sitemap and the redirect checker keep the exact addresses. The home's tool tiles now open their tool as a new document, so the analytics contract checks that the click's event still leaves and the new page sends exactly one page_view. The router's own page views, and the one on the way back, are checked on a docs-to-docs navigation instead.
…emap.xml exists VitePress 1.6.4 starts writing sitemap.xml through a stream in its build and does not wait for it, so the buildEnd hook can run before the file is there, as CI's build found. A step after `vitepress build`, like the redirect stubs, reads the finished file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The home, the tools, the extension's pages and the website privacy notice will be served by a separate build at the same addresses, while these docs stay on this VitePress site. VitePress treats every same-origin link as its own route, so once a page moves, a click from a docs page would render this site's old copy of it, or VitePress's 404 for a page it never built (
/tools).docs/.vitepress/tools/musician-pages.tsholds the one list of those paths (with their.htmlforms), the router decision, and the sitemap filter.router.onBeforeRouteChange: a navigation to a listed path doeslocation.assign(to)and returnsfalse, so the browser loads the page as a full document. Hash links on the same page never reach the router, and the router's first call on boot (with the current address) is let through, so a listed page this build serves is never reloaded.targetattribute or anything else in the HTML. Today a full load of a listed path serves the same VitePress page, so the whole list ships now and no later move needs a docs deploy.vitepress buildwrites/sitemap-docs.xml(VitePress doesn't wait for its own sitemap stream, sobuildEndcan run beforesitemap.xmlexists):sitemap.xmlminus the listed pages (61 of today's 71 URLs).sitemap.xmlstays byte-identical for now.checkRedirectsaccepts a listed page as a target even once this build stops emitting it. The 145 redirect stubs are byte-identical.How it was tested
HTML unchanged. CI's build of this branch (run 46310043572,
docs-siteartifact) against every one of the 231.htmlfiles live on www today (main 765c95f): 0 differ once content-hashed asset names, the inline page-hash map and the commit sha in the API pages' source links are masked. 76 differ before masking, all in those names only. All 145 redirect stubs andsitemap.xmlare byte-identical with no masking.sitemap-docs.xmllists 61 URLs,sitemap.xml's 71 minus the 10 musician pages it holds.Page comparison. A page-by-page comparison of what a crawler reads (status, redirects, headers, title, meta, canonical, og/twitter, JSON-LD, headings, visible text, links, images, analytics ids), with www as old, over
/, the six tool pages and/guide/getting-startedwith their.htmland slash variants: main's build served locally shows 0 unexplained differences, and this branch's build served locally shows 0 too. The two reports are identical apart from the local port.Browser (this branch's build served locally, every other host answered in the browser so nothing leaves the machine): a docs page's link to
/metronomeand to/loads a new document; a link to/guide/core-conceptsand a same-page#installationlink stay client-side in the same document; the first load of/metronome,/metronome.htmland/doesn't reload itself. On main's build the two full-load checks fail, as they should.Analytics contract (CI): the home's tool tile now opens its tool as a new document; the click's
bpm_home_tool_clickedstill arrives and the tool sends exactly one page_view with the home as referrer. The router's own page views, and the one on the way back, are checked on a docs-to-docs navigation.A fresh review found that VitePress lowercases paths and treats
foo,foo/andfoo/indexas one page; the decision now matches every such spelling.Each commit is a Conventional Commit
Tests cover the change:
docs/scripts/musician-pages.test.ts(the list, the decision for a listed page, a docs page, a same-page hash, the first load, another origin, the sitemap filter) and a new case indocs/scripts/redirects.test.tsIt changes no reading