Closed alex-page closed 5 years ago
Hi @alex-page, thanks for your interest.
I'd suggest to move the GitHub API functionality into a separate package and use @octokit/rest:
{{ 'alex-page/alex-page' | github('downloads') }}
{{ 'alex-page/alex-page' | github('license.name') }}
Looking at nunjucks async filter doc the .eleventy.js
would be configured like so:
module.exports = function(eleventyConfig) {
eleventyConfig.addNunjucksAsyncFilter("github", function(orgAndRepo, apiPart, callback) {
callToOctokit().then((results) => callback(null, results));
});
};
(I already have something with @octokit running on my own website) I feel that this will get unmaintainable quite fast. Just think about it. Next request would be about CPAN, then crates.io or rubygems.org or pypi.org or … Better to keep those separated IMHO.
What that work for you?
Sounds good to me
This package is really great but it could be more flexible to allow the user to get any data from an API. The user could provide a url:
The function would then return the body, they can then take the data out that they need.
Below is two examples of fetching data from two different sources. This could be one function to simplify the process:
Example function, you would need to use something like lodash got to get the nested data from the body object using the keypath:
The user could then access the data like so:
@Ryuno-Ki i have updated the issue, let me know if you have questions.