10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/readwise_curator/builder.rb', line 10
def build
api_key = config.readwise_curator&.api_key || ENV.fetch("READWISE_TOKEN", nil)
raise "Readwise API key not configured" unless api_key
all_books = fetch_all_books(api_key)
books_data = JSON.pretty_generate({
"count" => all_books.length,
"next" => nil,
"previous" => nil,
"results" => all_books,
})
data_dir = File.join(site.root_dir, "src/_data/readwise")
FileUtils.mkdir_p(data_dir)
File.write(File.join(data_dir, "books.json"), books_data)
end
|