-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
feat: update types #2156
feat: update types #2156
Conversation
β Deploy Preview for nuxt-content ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
src/runtime/composables/content.ts
Outdated
@@ -71,12 +71,12 @@ export const useContent = () => { | |||
/** | |||
* Next page from `surround`. | |||
*/ | |||
const next = computed(() => surround.value?.[1]) | |||
const next = computed(() => surround.value[1]) |
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 safe to keep this as optional because surround.value
could be undefined
src/runtime/composables/content.ts
Outdated
|
||
/** | ||
* Previous page from `surround`. | ||
*/ | ||
const prev = computed(() => surround.value?.[0]) | ||
const prev = computed(() => surround.value[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 is safe to keep this as optional because surround.value could be undefined
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.
In which case? As I can experiment, there is always a value and the object could be [null, null]
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.
surrounds
is set inside documentDriven.ts
only if HTTP call succeeds, if HTTP call fails surround will be null
Also, it will be null if users disable surrounds
in document driven.
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.
Ho yes, that's a good point.
src/runtime/types.d.ts
Outdated
/** | ||
* Layout | ||
*/ | ||
layout: string |
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.
layout
should be an optional field because it may or may not present in front-matter.
I'm also thinking of moving it to ParsedContentMeta
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.
Yes, good catch for the undefined.
Should we moved it to ParsedMeta, I don't know. I myself asked the question and I understand that ParsedMeta are calculated and because layout is not, I added here. But i'm completely open to move it.
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 think ParsedMeta
is better place for it
Will this allow typing the |
Could you tell me which |
@Barbapapazes I was thinking of sth like: const { page } = useContent<MyType>()
// ^? MyType This already works fine for |
Yes, that's will be possible! |
372eda0
to
b729f12
Compare
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.
Thanks β€οΈ
π Linked issue
β Type of change
π Description
I update types in
useContent
in order to have a better types completion and to allow user to pass it's own type.π Checklist