-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
674a04d
commit 88cffbc
Showing
5 changed files
with
140 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const imgPath = path.join(__dirname, 'img'); | ||
|
||
;(async () => { | ||
const data = []; | ||
const dir = await fs.promises.opendir(imgPath); | ||
for await (const dirent of dir) { | ||
const extname = path.extname(dirent.name || ''); | ||
if (/(svg|jpg|png)/.test(extname)) { | ||
data.push(`<span class="${extname.replace(/^\./, '')}" data-ext="${extname}" data-name="${dirent.name}"><img src="${dirent.name}" width="88" alt="${(dirent.name).replace(/.(svg|jpg|png)$/, '')}" /></span>`); | ||
} | ||
} | ||
|
||
const html = `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>logo</title> | ||
<style> | ||
:root { | ||
--jpg-color: #b4d9f7; | ||
--png-color: #e2b0ea; | ||
--svg-color: #ffd967; | ||
} | ||
body { text-align: center; margin: 0; } | ||
img { width: 88px; display: block; margin: 0 auto; } | ||
span { | ||
display: inline-block; | ||
border: 1px solid #d8d8d8; | ||
border-radius: 5px; | ||
margin: 5px 5px; | ||
padding: 5px; | ||
} | ||
span::before, span::after { | ||
text-align: left; | ||
display: block; | ||
font-size: 12px; | ||
background: #e4e4e4; | ||
border-radius: 3px; | ||
padding: 1px 3px; | ||
} | ||
span::before { | ||
content: attr(data-ext); | ||
margin-bottom: 5px; | ||
} | ||
span::after { | ||
content: attr(data-name); | ||
margin-top: 5px; | ||
} | ||
span.svg { border: 1px solid var(--svg-color); } | ||
span.svg::before { | ||
background: var(--svg-color); | ||
} | ||
span.png { border: 1px solid var(--png-color); } | ||
span.png::before { | ||
background: var(--png-color); | ||
} | ||
span.jpg { border: 1px solid var(--jpg-color); } | ||
span.jpg::before { | ||
background: var(--jpg-color); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
${data.join('')} | ||
</body> | ||
</html> | ||
`; | ||
await fs.promises.writeFile(path.join(imgPath, 'index.html'), html); | ||
console.log( | ||
'\x1b[32;1m Successfully created `index.html` file \x1b[0m\n', | ||
`=> \x1b[32;1m${path.join(imgPath, 'index.html')} \x1b[0m ` | ||
) | ||
})(); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
{ | ||
"name": "logo", | ||
"version": "1.0.0", | ||
"private": true, | ||
"homepage": "https://jaywcjlove.github.io/logo", | ||
"description": "", | ||
"scripts": { | ||
"start": "gh-pages -d img", | ||
"start": "node create.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jaywcjlove/logo.git" | ||
}, | ||
"keywords": [], | ||
"engines": { | ||
"node": ">=12.14.0" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/jaywcjlove/logo/issues" | ||
}, | ||
"dependencies": { | ||
"gh-pages": "^1.1.0" | ||
} | ||
} |