First of all, I wanted to thank you for your useful article which allowed me to finally find a solution to use a database with our static website (I was beginning to despair).
However, when I run the jekyll plugin, the yaml data file is only updated with 100 randomly picked entries of the table. I checked Airtable doc and there is an API record limit of 100, afterwhich another request must be made. Would you know how to ask the plugin to make multiple requests (one per page) in order to display all the records?
I found the answer to my own question in the airtable plugin’s documentation: all records can be queried through a series of batch request, by replacing
Yes sorry, I realise now my former message wasn’t clear at all!
I just changed one line in the jekyll plugin airtable.rb you display in your guide: instead of querying a set of records using records, I queried all using… all. Here is the full code:
require 'dotenv/load'
require 'airtable'
require 'active_support/all'
airtable = Airtable::Client.new(ENV['AIRTABLE_API_KEY'])
table = airtable.table(ENV['AIRTABLE_BASE'], ENV['AIRTABLE_TABLE'])
File.open("_data/#{ENV['AIRTABLE_TABLE']}.yml", 'w') do |file|
data = table.all.map(&:attributes)
warning = "# Do not edit this file manually \n"
file.write(warning, data.to_yaml)
end
Using all allows you to query all the rows of your table without paginating it, it just updates the _data folder with all the content of your table.
Another method could work, by getting the offset parameter at the end of each page of 100 rows you get with records, but then you’d have to multiply queries in order to loop through all the “pages” of your table (as it is explained in Airtable doc)