Repository navigation
Improve existing hooks. - #10
Merged
Merged
Conversation
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.
Summary
Page hooks now run on every page render, including dev-server re-renders. The package also exports the types hook and template authors need, and the ts-ssg README is corrected to match the code.
Page hooks run on every render
onPageStart,onPageRenderedandonPageWrittenused to fire only in full builds. Pages re-rendered inservewent throughbuildPage, which skipped them, so a hook that post-processed HTML worked inbuildand silently stopped working inserveafter the first edit.writePageWithHooksmethod incontent-state.ts, sobuildandserveproduce the same output.writeErrorPages(dev), a throwing hook during a re-render writes an error page, as it already did in full builds.buildPagehad no other callers and is removed.onConfigResolved,onContentDiscovered,onNavigationBuilt,onStylesWrittenandonBuildCompletestill run once per full build, deliberately. For example,onContentDiscoveredcan do expensive work, such as the studio writing its preview files.Exported types
@purestack/ts-ssgnow exports:BuildOptions,BuildCountSummary,BuildContext,PageRenderResult,ResolvedContentFile,WriteStylesResultPageTemplate,PageTemplateInput,PageTemplateMap,PageInfo,PageFrontmatterSiteConfig,SiteConfigInput,TsSsgContextPreviously a hook's context or a template's input couldn't be typed without importing internal paths.
README corrections
siteConfigandbuild.siteConfig.options.components, and corrects the claim that components never run in the browser (PageScript,RegorApp).themeSkinsandregisterSkinfrom@purestack/ts-style;builtInSkinsdoesn't exist.siteConfig.mdxoptions in place of a nonexistentBuildInput.mdx.page.htmlchanges inonPageRenderedare written, that hooks need the programmatic API, and an example.Every README code example was type-checked against the real exports.
Testing
page.htmlchanges reaching disk;