If we try to get this code working on a clean just created space, all works fine except for the fact thet get fetch stories call seems to return no results. This is unexpected since the default space contains one story with the name 'home'. After some debugging it became clear that this story does NOT have a last_author. So this line
will discard this as not correct therefore the isStory call also fails and the isStories call will also fail for all arrays that contain this default home story object.
This is confusing for a developer starting with plugin dev.
Since all manually made stories do have a valid last_author field, the best solution would be to tp make the default space initialized with stories that gave some fake last_author with a friendly_name of e.g. "J. Doe" so this code will not break here.
If it is more common to have stories without a last_author (e.g. after importing using the management API), it would be more appropriate to allow this code to work also on empty last_author fields.
If we try to get this code working on a clean just created space, all works fine except for the fact thet get fetch stories call seems to return no results. This is unexpected since the default space contains one story with the name 'home'. After some debugging it became clear that this story does NOT have a
last_author
. So this linehttps://github.com/storyblok/custom-app-examples/blob/4f669d7312913a94d864a71ff45886e9a9c4d386/app-nextjs-starter/src/Story.ts#L16C3-L16C17
will discard this as not correct therefore the
isStory
call also fails and theisStories
call will also fail for all arrays that contain this default home story object.This is confusing for a developer starting with plugin dev.
Since all manually made stories do have a valid
last_author
field, the best solution would be to tp make the default space initialized with stories that gave some fakelast_author
with afriendly_name
of e.g. "J. Doe" so this code will not break here.If it is more common to have stories without a
last_author
(e.g. after importing using the management API), it would be more appropriate to allow this code to work also on emptylast_author
fields.