Repository navigation
fix(content): import a page's own text, not its author box, icons or related posts - #1322
Conversation
…related posts Page URL import took the whole <body> when a page had no <main> or <article> (Webflow), and kept author boxes and share rows found inside <main>. It now finds the text area by its paragraphs, roots the content at the page's main block holding it (or at the block holding it and the H1), and takes out blocks named for furniture (author, share, related, comments, cta…), small link lists outside the text (breadcrumbs, icon rows, a few related posts, tables of contents), bylines, hidden elements, and avatar, logo, icon and cover images. Long lists of links such as a category's products stay whole. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Item D of the Plan feedback: Page URL import now brings only the page's own text. It drops author boxes, bylines, cover portraits, icon rows, tables of contents, related posts, promo cards and site footers.
Checks: server format, lint and 170 files / 2,010 tests pass. |
gkhngyk
left a comment
There was a problem hiding this comment.
A few fixes before merge:
server/src/lib/page-content.js:31:[hidden]and inlinedisplay:noneare now removed everywhere, including inside the text. Collapsed accordion panels often ship withhidden(orhidden="until-found"), and FAQ answers are exactly the text an AEO page needs. Move these three selectors out ofFRAMEinto a separate list. Apply that list afterfindTextArea, only to elements outside the text area, and keephidden="until-found". Add an FAQ accordion case topage-content.test.js.server/src/lib/page-content.js:349-351: when the root is the text area itself,parentsUntil(root)stops below it. This happens when an<article>or<main>holds the paragraphs directly, or when there is no<main>and the H1 sits inside the text. Thenabove.includes(textArea)is false, so images inside the text are judged by the page list (hero,featured,thumb,thumbnail), and an in-text image withsize-thumbnailis dropped. UsetextArea && (root[0] === textArea || above.includes(textArea)), asstripdoes at:339, and add a test.
The fetch path is unchanged. The brand-domain check still runs before and after redirects, and safe-fetch still refuses private addresses. The imported HTML still goes through cleanHtml on import and sanitizeDraftHtml on server-side draft writes.
…ge in-text images when the text is the root - [hidden] and inline display:none move out of FRAME: they're taken out after the text area is found, outside it only, and never hidden="until-found". The text area is found from visible paragraphs, so a hidden note beside the text doesn't widen it. - An image in the text area is judged by the in-text words when the root is the text area itself (an <article> holding the paragraphs directly), as strip does, so a size-thumbnail image in the text stays. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Thanks, both are in
Server: 2,012 tests, lint and Prettier pass. As a real-page check, www.ansvisor.com/pricing extracts identically before and after (its 10 FAQ answers aren't |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good. Both earlier findings are fixed in 8dd89303:
- Hidden blocks are no longer part of
FRAME.HIDDENis applied afterfindTextArea, only outside the text area, and it keepshidden="until-found". Paragraphs inside hidden blocks no longer count toward finding the text area. The FAQ accordion test covershidden,until-foundand inlinedisplay: none. - When the root is the text area itself, in-text images are judged by the in-text words (
root[0] === textArea || above.includes(textArea)), and there's a test for it.
Follow-up (low, can be a separate PR):
server/src/lib/page-content.js:276-282: an FAQ section that sits next to the text block, not inside it, still loses its hidden answers. A common layout is<main>with the post body, then an FAQ section whose questions are headings and whose answers arehidden. The text area is the post body because it holds all the visible paragraphs. So the FAQ's answers are outside it and get removed, but the root (<main>) keeps the questions. The import then has questions with no answers. Keep a hidden block when it is inside the root and follows a heading (h2–h6), which is the accordion's shape. Add a test with the FAQ after the text block.
Merges cleanly on current main. It contains no other open PR and adds no migration.
Tested on top of the current main: server tests (2,017), lint and Prettier pass. The URL import runs on the server, so it takes effect with the next AWS deploy.
Summary
From the user's review of a live draft: importing a page by URL (New content → Optimize content → Page URL) brought in more than the post. On prod draft
cfcaee7f…, imported from www.ansvisor.com/blog/ai-search-monitoring-tool-track-chatgpt-gemini-google-aio, it brought:The page is Webflow: it has no
<main>or<article>, soextractPageContentfell back to the whole<body>and removed onlynav,header,footerandaside. Pages that do have<main>often keep author boxes and share rows inside it, too.server/src/lib/page-content.jsnow:main/article/[role=main]/#contentwhen it holds that text;#links) go at any length.[hidden],display:noneand Webflow's.w-condition-invisible.coveris deliberately not a sign, because Tailwind'sobject-coveris on any picture.Links and images are still made absolute, the H1 still heads content whose H1 sits outside it, and the JSON-LD is unchanged.
Measured on real pages (old → new):
<article>referenceOn the blog post, every paragraph of the article, its 5 screenshots and its closing quote stay. On the Shopify page the products stay, and the category copy outside
<main>now comes in too.Related issue
None. Product feedback from the user.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
New tests in
page-content.test.jscover:<main>;Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — web not touchedyarn typecheckpasses (run fromweb/) — web not touchedyarn format:checkpasses (run fromweb/) — web not touchedServer:
npm run format,npm run lintandnpm test(170 files, 2,010 tests) pass. Server only, no migration.🤖 Generated with Claude Code