feat(Giscus): persist discussions via commentId #2132
+24
−1
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
commentIdwhen Giscus usesmapping="specific"so each page persists its own threadtermdata is missingquartz.layout.tswrappingComponent.Commentsbehind acommentIdguard so only eligible pages render the widgetLayout Example
In Quartz,
afterBodylets a theme append components after the main content. WrappingComponent.CommentsinComponent.ConditionalRenderensures the Giscus iframe is mounted only when the Markdown frontmatter declares acommentId, which prevents mis-mapping and matches Giscus’mapping: "specific"requirement.Why Guard
commentIdEverywherequartz/components/Comments.tsxblocks the initial component render when the term is missing, preventing Giscus from booting with stale props.quartz/components/scripts/comments.inline.tsre-checks during SPA navigations so client-side transitions never resurrect an iframe tied to a different page.quartz.layout.tskeeps the widget out of the static HTML build (SSG) entirely unless the page frontmatter opts in, avoiding accidental mounts.Component.Comments, so no caller can accidentally instantiate the widget without a matchingcommentId.