Startup Pro comes with Sanity.io integration for managing a Blog.
In this part of the documentation, we are going to show you how you can integrate Sanity into the Startup Pro Template and start your blog.
Follow the steps below to integrate Sanity into your Startup Pro Template.
Note: After the project is created successfully you’ll get a Sanity Studio installation command, we don’t need that here. Just close that window and follow the rest of the steps to complete the integration.
SANITY_PROJECT_ID=YOUR_PROJECT_ID
You can find the Sanity.config.ts file on the root of the template.
Add the URL as a CORS origin.
Choose the provider you want to log in with. We are going to log in with GitHub
The integration is done!
Let’s go ahead and see how you can add an Article and an Author to your blog.
The author is created successfully, now let’s write an article.
After that click on the Publish button to publish the article.
If everything is done correctly you’ll see the article on the Blog page.
Name: Give a descriptive name to your API key.
Permission: Give editor access.
Now hit the save button.
After you hit the save button you’ll get an API key. Copy the key and save it to the env file:
SANITY_PROJECT_API_TOKEN=YOUR_API_KEY
Sanity webhook is used for on-demand data revalidation. In this part of the documentation, we will show you how to integrate a Sanity webhook into your project.
Follow the steps to integrate webhook:
Name: Give your webhook a name.
Description: Describe the function of your webhook (This is an optional field).
URL: Set the URL to https://YOUR_SITE_URL/api/revalidate
Dataset: Choose your desired dataset or leave the default value.
Trigger on: Set the hook to trigger on "Create", "Update", and "Delete".
Filter: Leave this field blank.
Projections: Set the projections to {_type, "slug":
slug.current}
Status: Check the enable webhook box.
HTTP Method: POST.
Leave HTTP headers, API version, and Draft as default.
Secret: Give your webhook a unique secret and copy it.
Hit save once completed to create your webhook.
Note: you can’t test webhook in the dev environment.
SANITY_HOOK_SECRET=YOUR_SECRET