Skip to content

Commit

Permalink
Revert "Create img badges directly in jekyll" (Leaflet#8719)
Browse files Browse the repository at this point in the history
  • Loading branch information
Falke-Design authored Dec 18, 2022
1 parent 6877150 commit 8eb4e47
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 28 deletions.
2 changes: 0 additions & 2 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ integrity_hash_uglified: "sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
collections:
plugins:
output: false

plugins_dir: modules
2 changes: 1 addition & 1 deletion docs/_includes/plugin_category_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<td><a class="plugin-repo-url" href="{{ plugin.repo }}">{{ plugin.name }}</a></td>
<td>
{{ plugin.content }}
<div class="repo-data">{{ plugin.repo | createBadges }}</div>
<div class="repo-data"></div>
</td>
<td>
{% if plugin.demo %}
Expand Down
25 changes: 0 additions & 25 deletions docs/modules/badges_filter.rb

This file was deleted.

53 changes: 53 additions & 0 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,56 @@ Leaflet keeps it simple. If you can think of a feature that is not required by a
There are no hard requirements on how to create your own plugin, but all developers are encouraged to read the recommendations in the [plugin guide](https://github.com/Leaflet/Leaflet/blob/main/PLUGIN-GUIDE.md).

Once your plugin is ready, you can submit it: just send a pull request with a new plugin file in [/docs/_plugins/](https://github.com/Leaflet/Leaflet/tree/main/docs/_plugins)to our GitHub repository.

<script>
function loadRepoData() {
const regexpGithubCom = /^https?:\/\/(?:www\.)?github\.com\/([\w\d-_.]+)\/([\w\d-_.]+)\/?/;
const regexpGithubIO = /^https?:\/\/([\w\d-_.]+)\.github\.io\/([\w\d-_.]+)\/?/;
const regexpGitlabCom = /^https?:\/\/(?:www\.)?gitlab\.com\/([\w\d-_.]+)\/([\w\d-_.]+)\/?/;

const rows = document.querySelectorAll('table.plugins tr');
rows.forEach((row) => {
try {
const repoData = row.querySelector('.repo-data');
if (repoData) {
const link = row.querySelector('.plugin-repo-url').href;
let badges = [];

const matchGithubCom = link.match(regexpGithubCom);
if (matchGithubCom) {
const repo = `${matchGithubCom[1]}/${matchGithubCom[2]}`;
badges = [
`https://badgen.net/github/stars/${repo}`,
`https://badgen.net/github/last-commit/${repo}`
];
}

const matchGithubIO = link.match(regexpGithubIO);
if (matchGithubIO) {
const repo = `${matchGithubIO[1]}/${matchGithubIO[2]}`;
badges = [
`https://badgen.net/github/stars/${repo}`,
`https://badgen.net/github/last-commit/${repo}`
];
}

const matchGitlabCom = link.match(regexpGitlabCom);
if (matchGitlabCom) {
const repo = `${matchGitlabCom[1]}/${matchGitlabCom[2]}`;
badges = [
`https://badgen.net/gitlab/stars/${repo}`,
`https://badgen.net/gitlab/last-commit/${repo}`
];
}

badges.forEach((badge) => {
repoData.innerHTML += `<img src="${badge}" alt=""/>`;
});
}
} catch (e) {
console.error(e);
}
});
}
loadRepoData();
</script>

0 comments on commit 8eb4e47

Please sign in to comment.