Skip to content

Commit 3f38ec5

Browse files
committed
fetch latest release via github api and use it for showing the header and CDN links
1 parent 843c073 commit 3f38ec5

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

docs/assets/js/script.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ var devicon = angular.module('devicon', ['ngSanitize', 'ngAnimate']);
88

99
devicon.controller('IconListCtrl', function($scope, $http, $compile) {
1010

11+
// Determination of the latest release tagging
12+
// which is used for showing in the header of the page
13+
// as well as for CDN links
14+
var gitHubPath = 'devicons/devicon';
15+
var url = 'https://api.github.com/repos/' + gitHubPath + '/tags';
16+
$scope.latestReleaseTagging = 'master';
17+
$http.get(url).success(function (data) {
18+
if(data.length > 0) {
19+
$scope.latestReleaseTagging = data[0].name;
20+
}
21+
}).error(function () {
22+
console.log('Unable to determine latest release version, fallback to master.')
23+
});
24+
25+
1126
var baseUrl = window.location.origin + '/dist';
1227

1328
// Get devicon.json
@@ -69,7 +84,6 @@ devicon.controller('IconListCtrl', function($scope, $http, $compile) {
6984
/*------ End of "Re-format devicon.json" ------*/
7085
});
7186

72-
7387
/*
7488
| Change selected icon
7589
|--------------------------------

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
<div class="container">
4848
<header class="clearfix">
49-
<h1>Devicon <span>2.7</span></h1>
49+
<h1>Devicon <span><a href="https://github.com/devicons/devicon/releases">{{ latestReleaseTagging }}</a></span></h1>
5050
<h2>Devicon is a set of icons representing programming languages, designing & development tools. You can use it as a font or directly copy/paste the svg code into your project.</h2>
5151
<h3>(Super) Quick Setup</h3>
5252
<h5>First select an icon on the right, then select the version below and copy/paste the code into your project.</h5>
@@ -65,7 +65,7 @@ <h4>Font versions</h4>
6565
</ul>
6666
<div class="cde">
6767
<div class="cde-com">&lt;!-- in your header --&gt;</div>
68-
&lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devicons/devicon@master/devicon.min.css"&gt;<br />
68+
&lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devicons/devicon@{{ latestReleaseTagging }}/devicon.min.css"&gt;<br />
6969
<br />
7070
<div class="cde-com">&lt;!-- in your body --&gt;</div>
7171
&lt;i class="devicon-{{selectedIcon.name}}-{{selectedFontIcon}}<span ng-if="colored"> colored</span>"&gt;&lt;/i&gt;<br />

0 commit comments

Comments
 (0)