Skip to content

Commit 0e0c800

Browse files
Merge pull request #278 from aeadedoyin/feat/redirect-assets
Feat/redirect assets
2 parents d2cf75e + 4644217 commit 0e0c800

File tree

13 files changed

+4002
-5844
lines changed

13 files changed

+4002
-5844
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 31 deletions
This file was deleted.

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

eslint.config.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import js from '@eslint/js';
2+
import eslintConfigPrettier from 'eslint-config-prettier';
3+
import prettierPlugin from 'eslint-plugin-prettier';
4+
5+
export default [
6+
{
7+
ignores: ['node_modules/**', 'templates/**', 'gulpfile.js', 'css/**', 'eslint.config.js'],
8+
},
9+
js.configs.recommended,
10+
{
11+
languageOptions: {
12+
ecmaVersion: 2022,
13+
sourceType: 'script',
14+
globals: {
15+
window: 'readonly',
16+
document: 'readonly',
17+
navigator: 'readonly',
18+
console: 'readonly',
19+
},
20+
},
21+
plugins: {
22+
prettier: prettierPlugin,
23+
},
24+
rules: {
25+
'prettier/prettier': ['error'],
26+
'no-use-before-define': ['error', { functions: false, classes: false }],
27+
'no-param-reassign': ['warn'],
28+
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
29+
'max-len': [
30+
'error',
31+
{
32+
code: 150,
33+
ignoreTemplateLiterals: true,
34+
ignoreStrings: true,
35+
},
36+
],
37+
'no-shadow': ['error'],
38+
'no-plusplus': ['off'],
39+
'no-mixed-operators': ['error'],
40+
},
41+
},
42+
eslintConfigPrettier,
43+
];

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<div class="scroll-show">
5555
<div class="white-bg"></div>
5656
<div class="site-logo">
57-
<a href="/"><img src="images/nigerialogos_logo.svg" alt="NigeriaLogos logo"></a>
57+
<a href="/"><img src="images/NigeriaLogos_logo.svg" alt="NigeriaLogos logo"></a>
5858
</div>
5959
<div class="secondary-alphabet"><a href="##">#</a></div>
6060
<div class="searchbar">
@@ -72,7 +72,7 @@
7272
</div>
7373
<div class="heading">
7474
<div class="site-logo">
75-
<a href="/"><img src="images/nigerialogos_logo.svg" alt="NigeriaLogos logo"></a>
75+
<a href="/"><img src="images/NigeriaLogos_logo.svg" alt="NigeriaLogos logo"></a>
7676
</div>
7777
<h1>NigeriaLogos, an <a href="https://github.com/PaystackHQ/nigerialogos" target="_blank">open source</a>
7878
collection<br>of high quality, pixel perfect Nigerian<br>company logos for free use.</h1>

js/imageLoad.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const loadJSON = callback => {
1818
};
1919

2020
const sortObjectArray = (array, key) => {
21-
return array.sort(function(a1, a2) {
21+
return array.sort(function (a1, a2) {
2222
const b1 = a1[key].toLowerCase();
2323
const b2 = a2[key].toLowerCase();
2424

@@ -32,12 +32,12 @@ const sortObjectArray = (array, key) => {
3232

3333
const isValidURL = url => {
3434
let urlInstance;
35-
try {
36-
urlInstance = new URL(url);
37-
} catch (_) {
38-
return false;
39-
}
40-
return urlInstance.protocol === "http:" || urlInstance.protocol === "https:";
35+
try {
36+
urlInstance = new URL(url);
37+
} catch (_) {
38+
return false;
39+
}
40+
return urlInstance.protocol === 'http:' || urlInstance.protocol === 'https:';
4141
};
4242

4343
const setLogoCompanyLink = logoArray => {

js/mobileDownload.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
window.addEventListener('load', ()=> {
2-
const links = document.querySelectorAll('.logo__download__overlay a');
3-
let clicks = 0;
4-
const stopLink = function (e) {
5-
clicks ++;
6-
// Prevent download on first clicks so as to enable hover effect on mobile
7-
if (clicks % 2 !== 0) e.preventDefault();
8-
9-
}
10-
if ('ontouchstart' in window || 'ontouch' in window) {
11-
links.forEach(link => {
12-
link.addEventListener('click', stopLink);
13-
})
14-
}
15-
})
1+
window.addEventListener('load', () => {
2+
const links = document.querySelectorAll('.logo__download__overlay a');
3+
let clicks = 0;
4+
const stopLink = function (e) {
5+
clicks++;
6+
// Prevent download on first clicks so as to enable hover effect on mobile
7+
if (clicks % 2 !== 0) e.preventDefault();
8+
};
9+
if ('ontouchstart' in window || 'ontouch' in window) {
10+
links.forEach(link => {
11+
link.addEventListener('click', stopLink);
12+
});
13+
}
14+
});

js/scroll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function() {
1+
(function () {
22
const main = document.querySelector('main');
33
const scrollShow = document.querySelector('.scroll-show');
44
const secondaryAlphabet = document.querySelector('.secondary-alphabet');

js/search.js

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,33 @@ const updateSearchState = () => {
2828

2929
// Escape meta-characters to prevent DOM->HTML XSS
3030
function escapeHtml(text) {
31-
return text
32-
.replace(/&/g, "&amp;")
33-
.replace(/</g, "&lt;")
34-
.replace(/>/g, "&gt;")
35-
.replace(/"/g, "&quot;")
36-
.replace(/'/g, "&#39;");
31+
return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
3732
}
3833

3934
const highlightSearchTerm = (logo, term) => {
40-
const logoText = logo.querySelector('.logo__text--link');
41-
const logoTextTitle = logoText.textContent;
42-
if (!term) {
43-
logoText.innerHTML = escapeHtml(logoTextTitle);
44-
return;
45-
}
46-
// Escape and highlight term
47-
// Use a global, case-insensitive regex
48-
// We escape fragments, but wrap matches in <mark>
49-
const regex = new RegExp(term, 'gi');
50-
let lastIndex = 0;
51-
let html = '';
52-
let match;
53-
while ((match = regex.exec(logoTextTitle)) !== null) {
54-
// Escape the text before the match
55-
html += escapeHtml(logoTextTitle.substring(lastIndex, match.index));
56-
// Highlight the match (escape just in case)
57-
html += `<mark>${escapeHtml(match[0])}</mark>`;
58-
lastIndex = regex.lastIndex;
59-
}
60-
// Escape the rest after last match
61-
html += escapeHtml(logoTextTitle.substring(lastIndex));
62-
logoText.innerHTML = html;
35+
const logoText = logo.querySelector('.logo__text--link');
36+
const logoTextTitle = logoText.textContent;
37+
if (!term) {
38+
logoText.innerHTML = escapeHtml(logoTextTitle);
39+
return;
40+
}
41+
// Escape and highlight term
42+
// Use a global, case-insensitive regex
43+
// We escape fragments, but wrap matches in <mark>
44+
const regex = new RegExp(term, 'gi');
45+
let lastIndex = 0;
46+
let html = '';
47+
let match;
48+
while ((match = regex.exec(logoTextTitle)) !== null) {
49+
// Escape the text before the match
50+
html += escapeHtml(logoTextTitle.substring(lastIndex, match.index));
51+
// Highlight the match (escape just in case)
52+
html += `<mark>${escapeHtml(match[0])}</mark>`;
53+
lastIndex = regex.lastIndex;
54+
}
55+
// Escape the rest after last match
56+
html += escapeHtml(logoTextTitle.substring(lastIndex));
57+
logoText.innerHTML = html;
6358
};
6459

6560
const onSearch = e => {

0 commit comments

Comments
 (0)