Get a list of posts in a databse on Notion and parse it to the 11ty.
Follow Step 1 & Step 2 in this official tutorial. Note that, we don't use
@notionhq/client
, so you don't have to install it. Instead, install following packages,Create an
.env
file on the project directory + add ".env" to .gitignore
!In your
_data
folder, create notion.js
(or whatever you want).If you request the API within 1 day (
duration: "1d"
in the above codes), it keeps using the .cache
and you may not see the newest changes from the API! In this case, you can remove .cache
and try again!Go to the official API site for more use cases.
You can use Postman or any other API platform to try the queries from Notion API first.
An example of the returned json (before the line
json = json.
),A return result will be stored in
notion.json
, you can use it in your template as {{ notion.json }}
. Note that, the word "notion" is corresponding to the name of the file notion.js
!To show the list of titles from the returned json,
The result will be,