Created
February 12, 2021 17:00
-
-
Save iansu/849e7a071e67ceb7511958d50fe7c4f1 to your computer and use it in GitHub Desktop.
Butter CMS Integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Butter from 'buttercms'; | |
const butter = Butter('api_key'); | |
const getHomePage = async () => { | |
const homePage = await butter.page.retrieve('*', 'sample-page'); | |
return homePage.data.data; | |
}; | |
const getPostBySlug = async (slug: string) => { | |
const page = await butter.post.retrieve(slug); | |
return page.data.data; | |
}; | |
const getPosts = async (number: number) => { | |
const posts = await butter.post.list({ page_size: number }); | |
return posts.data.data; | |
}; | |
export { getHomePage, getPostBySlug, getPosts }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment