Repository navigation
Spread blog ad units across top, mid-article, and bottom - #113
Merged
Merged
Conversation
Both units were stacked at the bottom of the page, which is the lowest-value placement and looks like a footer dump. Spread them out: - Post page: one above the body, one mid-article, one after the article. - Index: one above the list, one after the 3rd card (only when the list has 6+ posts, else it's just the bottom unit again), one below. Mid-article means cutting rendered post HTML in half, and a naive cut at the halfway character lands inside a list, blockquote or code block and leaves unbalanced tags in both halves. splitHtmlForMidAd only cuts after a top-level block closes, tracking container depth as it scans. A single big block can straddle the midpoint and leave no boundary in the preferred 25-75% window; rather than drop the unit on exactly those long posts, it falls back to a wider window before giving up. Short posts and plain-text bodies get no mid unit at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
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.
Follow-up to #112, which stacked both ad units at the bottom of the page — the lowest-value placement.
Post page (
/blog/[slug]): one unit above the body, one mid-article, one after the article.Index (
/blog): one above the list, one after the 3rd card, one below the list. The mid-list unit only appears when there are 6+ posts, otherwise it's just the bottom unit again.Mid-article placement means cutting the rendered post HTML in half. A naive cut at the halfway character routinely lands inside a list, blockquote or code block and leaves unbalanced tags in both halves (the bodies are injected with
dangerouslySetInnerHTML), solib/blog/split-html.tsonly cuts after a top-level block element closes, tracking container depth as it scans.One case the tests turned up: a single big block (long list, 200-line code sample) can straddle the midpoint and leave no legal boundary inside the preferred 25–75% window. Rather than silently drop the mid unit on exactly those long posts, it retries in a wider window before giving up. Short posts and plain-text bodies get no mid unit at all.
8 unit tests in
tests/split-html.test.tscover the balanced-tag guarantees (list / blockquote / code block), the midpoint bounds, and the null cases. Full suite: 434 passing./blogroute caching is unchanged.