-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entry Emulator - Summary Block #2638
Conversation
|
db/model/Gdoc/htmlToEnriched.ts
Outdated
"type" in content.content[0] && | ||
content.content[0].type === "list" | ||
if (contentIsList) { | ||
const listItems = get(content, ["content", 0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like "items" is missing and so list-based summary blocks (e.g. https://ourworldindata.org/working-hours) return an empty block (yet visible and expandable).
const listItems = get(content, ["content", 0]) | |
const listItems = get(content, ["content", 0, "items"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof! Sorry about that! You're right, I removed it for the callout refactor and then forgot to change it back.
// Summaries can either be lists of anchor links, or paragraphs of text | ||
// If it's a paragraph of text, we want to turn it into a callout block | ||
// If it's a list of anchor links, we want to turn it into a toc block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a summary block is both text and list (e.g. https://ourworldindata.org/vaccination), both conditions get skipped below and the summary gets stripped out of the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we don't really have a way to render a similar component in Gdocs. Instead we'll track it and deal with it manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, I'd missed the last error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I'm not aware of a particular process to go through WP to Gdoc migration errors. Is there anything in place yet, that uses the info in the archieml_update_statistics column (other than the per doc "migration error" button)?
db/model/Gdoc/htmlToEnriched.ts
Outdated
| "summary item isn't text" | ||
| "summary item doesn't have link" | ||
| "summary item has DataValue" | ||
| "Unknown content type inside summary block" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove capitalization for consistency
// Summaries can either be lists of anchor links, or paragraphs of text | ||
// If it's a paragraph of text, we want to turn it into a callout block | ||
// If it's a list of anchor links, we want to turn it into a toc block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, I'd missed the last error
db/model/Gdoc/rawToEnriched.ts
Outdated
if (!item.text) { | ||
parseErrors.push({ | ||
message: `entry-summary item ${i} is missing text`, | ||
}) | ||
} else if (!item.slug) { | ||
parseErrors.push({ | ||
message: `Entry summary item with text ${item.text} is missing a url`, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this isn't too precise for the type of malformed content we can have, and ends up being misleaing in some cases, e.g.:
text: Outdoor air pollution is one of the leading risk factors for premature death.
slug: outdoor-air-pollution-is-one-of-the-leading-risk-factors-for-premature-death
slug: ignored
slug: also ignored
slug: one ignored
text: One ignored
slug: two ignored
text: Two
Maybe we could be more helpul by staying generic in the error description and rather showing the expected shape of the content.
@@ -17,6 +17,136 @@ import { | |||
adjustHeadingLevels, | |||
} from "./model/Gdoc/htmlToEnriched.js" | |||
|
|||
// Hard-coded slugs to avoid WP dependency | |||
const entries = new Set([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mind explaining how you generated this list of slugs?
}) | ||
.with({ type: "entry-summary" }, (block) => { | ||
return toc ? ( | ||
<TableOfContents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this check makes sense here
Some quick and dirty groundwork for the entry emulator (hard-coding entry slugs) plus migration code for the summary block.
I made the
SDGTableOfContents
component slightly more generic to suit these two usecases.This doesn't work for summary headings with data values in them, or summaries that have images in them. In the interests of velocity I nominate we track those (via the error messages I've added) and manually update them.
Datasette view of all our entries with summary blocks