-
Notifications
You must be signed in to change notification settings - Fork 9
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
fix see more #464
fix see more #464
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -132,7 +132,7 @@ export type AnswersRow = CodaRowCommon & { | |||||||||||||||||||||||||||||||
Banners: '' | Entity[] | ||||||||||||||||||||||||||||||||
'Rich Text': string | ||||||||||||||||||||||||||||||||
Subtitle?: string | ||||||||||||||||||||||||||||||||
Icon?: string | ||||||||||||||||||||||||||||||||
Icon?: Entity | string | Entity[] | ||||||||||||||||||||||||||||||||
Parents?: Entity[] | ||||||||||||||||||||||||||||||||
Order?: number | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
@@ -250,7 +250,7 @@ const renderText = (pageid: PageId, markdown: string | null): string | null => { | |||||||||||||||||||||||||||||||
if (!markdown) return null | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
markdown = extractText(markdown) | ||||||||||||||||||||||||||||||||
markdown = urlToIframe(markdown) | ||||||||||||||||||||||||||||||||
markdown = urlToIframe(markdown || '') | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
let html = convertToHtmlAndWrapInDetails(markdown) | ||||||||||||||||||||||||||||||||
html = uniqueFootnotes(html, pageid) | ||||||||||||||||||||||||||||||||
|
@@ -260,8 +260,17 @@ const renderText = (pageid: PageId, markdown: string | null): string | null => { | |||||||||||||||||||||||||||||||
return html | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
// Icons can be returned as strings or objects | ||||||||||||||||||||||||||||||||
const extractIcon = (val?: string | string[] | Entity | Entity[]): string | undefined => { | ||||||||||||||||||||||||||||||||
if (!val) return val | ||||||||||||||||||||||||||||||||
const item = head(val) | ||||||||||||||||||||||||||||||||
if (typeof item === 'string') return extractText(val as string) | ||||||||||||||||||||||||||||||||
if (item) return (item as Entity).url | ||||||||||||||||||||||||||||||||
return undefined | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+266
to
+271
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be nice to avoid the
Suggested change
I also think the last There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the thing is that I know that if it's not a string and not undefined, then it's going to be an Wouldn't that be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah maybe part of the confusion here is that in my local code where I was trying this out, I also changed the signature of the The way I'm reasoning about it is that the parameter type is
At any rate, I'll make a PR at some point to improve the
No, I don't think so. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ohhh, I like that version of head! |
||||||||||||||||||||||||||||||||
// Sometimes string fields are returned as lists. This can happen when there are duplicate entries in Coda | ||||||||||||||||||||||||||||||||
const head = (item: string | string[]) => { | ||||||||||||||||||||||||||||||||
const head = (item: any | any[]) => { | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it would be more type-safe down the line to use
Suggested change
|
||||||||||||||||||||||||||||||||
if (Array.isArray(item)) return item[0] | ||||||||||||||||||||||||||||||||
return item | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
@@ -291,7 +300,7 @@ const convertToQuestion = ({name, values, updatedAt} = {} as AnswersRow): Questi | |||||||||||||||||||||||||||||||
status: values['Status']?.name as QuestionStatus, | ||||||||||||||||||||||||||||||||
alternatePhrasings: extractText(values['Alternate Phrasings']), | ||||||||||||||||||||||||||||||||
subtitle: extractText(values.Subtitle), | ||||||||||||||||||||||||||||||||
icon: extractText(values.Icon), | ||||||||||||||||||||||||||||||||
icon: extractIcon(values.Icon), | ||||||||||||||||||||||||||||||||
parents: !values.Parents ? [] : values.Parents?.map(({name}) => name), | ||||||||||||||||||||||||||||||||
updatedAt: updatedAt || values['Doc Last Edited'], | ||||||||||||||||||||||||||||||||
order: values.Order || 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.
This type change doesn't seem necessary as far as I can tell. The new
extractIcon
function returnsstring | undefined
, so I think that is a suitable type here.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.
this is here mainly to document what Coda returns. Which can be either the raw image (base64 encoded), an url to the image, a reference to a Coda item or a list of references to Coda items... I'm not sure what exactly causes what