Skip to content

Commit

Permalink
🐛 correctly parse URLs in gdoc front matter
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Apr 22, 2024
1 parent aff9e76 commit 74f9b24
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion db/model/Gdoc/archieToEnriched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import { convertHeadingTextToId } from "@ourworldindata/components"
import { parseRawBlocksToEnrichedBlocks, parseRefs } from "./rawToEnriched.js"
import urlSlug from "url-slug"
import { parseAuthors, spansToSimpleString } from "./gdocUtils.js"
import { extractUrl, parseAuthors, spansToSimpleString } from "./gdocUtils.js"
import { htmlToSimpleTextBlock } from "./htmlToEnriched.js"
import { RESEARCH_AND_WRITING_DEFAULT_HEADING } from "@ourworldindata/types"

Expand Down Expand Up @@ -305,6 +305,14 @@ export const archieToEnriched = (
if (parsed[key] === "false") parsed[key] = false
}

// Convert URL front-matter properties to URLs
for (const key of Object.keys(parsed)) {
const value = parsed[key]
if (typeof value === "string") {
parsed[key] = extractUrl(value)
}
}

// Parse elements of the ArchieML into enrichedBlocks
parsed.body = compact(parsed.body.map(parseRawBlocksToEnrichedBlocks))

Expand Down

0 comments on commit 74f9b24

Please sign in to comment.