-
Notifications
You must be signed in to change notification settings - Fork 81
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
WP stories #1973
WP stories #1973
Conversation
e86cad6
to
4c15761
Compare
459f77b
to
21a819b
Compare
stories: Array<StoriesTemplateWithThumbs>; | ||
} | ||
|
||
export type StoriesAPI = { |
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.
convert to interface
thumbnailHeight: number; | ||
} | ||
|
||
export type StoryPages = { |
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.
convert to interface
project: id, | ||
name: title, | ||
cat: categories.split(",").map((cat) => cat.trim()), | ||
color: "#d7fb00", |
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 is ok this color to be hardcoded ?
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.
We have some parts that are temporary hardcoded, color and styles, in future we will fix it
categories: kit.categories, | ||
types: kit.types as KitType[] | ||
blank, | ||
project: blank ? pages[0].id : name, |
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.
move pages[0]
in some const and if you have an parser for page, then use it
const page = parser(pages[0]);
thumbnailHeight, | ||
thumbnailWidth, | ||
thumbnailSrc: `${url}/${id}.jpg`, | ||
pro: pro ?? false, |
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.
pro: !!pro
styles, | ||
pro: isPro, | ||
thumbnailSrc: `${thumbUrl}/${pages[0].id}.jpg`, | ||
thumbnailWidth: pages[0].thumbnailWidth, |
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.
same here, move pages[0]
in some const
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 Layout converter and will be fixed in Layout PR
4c15761
to
46a2245
Compare
70ae191
to
a4246a6
Compare
3391208
to
20feb9d
Compare
376a03f
to
75a4ae8
Compare
ec4a20a
to
ed86dcd
Compare
f8af8c4
to
2ff72cc
Compare
ed86dcd
to
1cc7e37
Compare
86b3bc9
to
1388183
Compare
ff5d56a
to
f10764f
Compare
7341a4d
to
b28625c
Compare
ca90731
to
0e8026a
Compare
9319590
to
a9b7fd9
Compare
13d3a03
to
e492873
Compare
10b656c
to
7857acb
Compare
8421056
to
000c60f
Compare
6718ed2
to
43677e1
Compare
return Json.read(data[0].pageData) as { | ||
items: DefaultBlockWithID[]; | ||
}; |
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.
`${url}/get-story-page-data?project_id=${layoutId}&page_slug=${id}` | ||
).then((r) => r.json()); | ||
|
||
const pageData = JSON.parse(data.collection); |
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.
use Json.read
or wrap in try/catch json parsing
return pageData as { | ||
blocks: DefaultBlock[]; | ||
}; |
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.
remove casting
if without casting is not possible then validate it, as example if pageData will be undefined/null then return empty array
name: title, | ||
cat: categories.split(",").map((item) => item.trim()), | ||
color, | ||
pagesCount: Number(pagesCount), |
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.
cat: categories.length | ||
? categories.split(",").map((cat) => cat.trim()) | ||
: [], | ||
color: color, |
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.
write short: color: color
-> color
return allElements; | ||
}; | ||
export function convertToCategories(obj: Record<string, string>): Categories[] { | ||
return Object.entries(obj).map(([_, title]) => ({ |
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.
use Object.value(obj)
instead of Object.entries(obj)
to void using of _
for skip an variable
26f635a
to
6d25b21
Compare
6522cff
to
47e9acc
Compare
52ba1ab
to
c69f859
Compare
6d25b21
to
e080c51
Compare
e080c51
to
d51ca87
Compare
7374952
to
f0686f3
Compare
new PR on beta #2004 |
Related issue https://github.com/bagrinsergiu/blox-editor/issues/25400