ContentType
ContentType
A content type is the structure or blueprint of a page or a section that your web or mobile property will display. It lets you define the overall schema of this blueprint by adding fields and setting its properties.
Example:
import { BaseContentType } from '@contentstack/delivery-sdk'
interface BlogPost extends BaseContentType {
text: string;
// other custom props
}
async function fetchContentType() {
try {
const contentType = await stack.contentType("blog").fetch<BlogPost>();
console.log(contentType);
//Add your statements
} catch (error) {
console.error("Error fetching content type:", error);
}
}
fetchContentType();| Name | Type | Description |
|---|---|---|
| contentTypeUid | string | UID of the content type |
entry
The entry method creates an entry object for the specified entry.
| Name | Type | Description |
|---|---|---|
| uid | string | UID of the entry |
Example:
const entry = stack.contentType("contentTypeUid").entry("entryUid");fetch
The fetch method retrieves the details for the specified content type.
Example:
const result = await stack.contentType("contentTypeUid").fetch<BlogPost>();