mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed missing pagination on GitHub API
This commit is contained in:
parent
18b2ca47b2
commit
cc7facb199
File diff suppressed because one or more lines are too long
@ -150,7 +150,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ base_url }}/assets/javascripts/application-1d6ee6ee6c.js"></script>
|
<script src="{{ base_url }}/assets/javascripts/application-6940329b9f.js"></script>
|
||||||
{% set languages = lang.t("search.languages").split(",") %}
|
{% set languages = lang.t("search.languages").split(",") %}
|
||||||
{% if languages | length and languages[0] != "" %}
|
{% if languages | length and languages[0] != "" %}
|
||||||
{% set path = base_url + "/assets/javascripts/lunr" %}
|
{% set path = base_url + "/assets/javascripts/lunr" %}
|
||||||
|
@ -59,28 +59,37 @@ export default class GitHub extends Abstract {
|
|||||||
* @return {Promise<Array<string>>} Promise returning an array of facts
|
* @return {Promise<Array<string>>} Promise returning an array of facts
|
||||||
*/
|
*/
|
||||||
fetch_() {
|
fetch_() {
|
||||||
return fetch(this.base_)
|
const paginate = (page = 0) => {
|
||||||
.then(response => response.json())
|
return fetch(`${this.base_}?per_page=30&page=${page}`)
|
||||||
.then(data => {
|
.then(response => response.json())
|
||||||
if (!(data instanceof Array))
|
.then(data => {
|
||||||
throw new TypeError
|
if (!(data instanceof Array))
|
||||||
|
throw new TypeError
|
||||||
|
|
||||||
/* Display number of stars and forks, if repository is given */
|
/* Display number of stars and forks, if repository is given */
|
||||||
if (this.name_) {
|
if (this.name_) {
|
||||||
const repo = data.find(item => item.name === this.name_)
|
const repo = data.find(item => item.name === this.name_)
|
||||||
return repo
|
if (!repo && data.length === 30)
|
||||||
? [
|
return paginate(page + 1)
|
||||||
`${this.format_(repo.stargazers_count)} Stars`,
|
|
||||||
`${this.format_(repo.forks_count)} Forks`
|
/* If we found a repo, extract the facts */
|
||||||
|
return repo
|
||||||
|
? [
|
||||||
|
`${this.format_(repo.stargazers_count)} Stars`,
|
||||||
|
`${this.format_(repo.forks_count)} Forks`
|
||||||
|
]
|
||||||
|
: []
|
||||||
|
|
||||||
|
/* Display number of repositories, otherwise */
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
`${data.length} Repositories`
|
||||||
]
|
]
|
||||||
: []
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/* Display number of repositories, otherwise */
|
/* Paginate through repos */
|
||||||
} else {
|
return paginate()
|
||||||
return [
|
|
||||||
`${data.length} Repositories`
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2020,9 +2020,9 @@ flatten@^1.0.2:
|
|||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
|
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
|
||||||
|
|
||||||
flow-bin@^0.51.1:
|
flow-bin@^0.52.0:
|
||||||
version "0.51.1"
|
version "0.52.0"
|
||||||
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.51.1.tgz#7929c6f0a94e765429fcb2ee6e468278faa9c732"
|
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.52.0.tgz#b6d9abe8bcd1ee5c62df386451a4e2553cadc3a3"
|
||||||
|
|
||||||
flow-jsdoc@^0.3.0:
|
flow-jsdoc@^0.3.0:
|
||||||
version "0.3.0"
|
version "0.3.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user