Skip to content

Commit

Permalink
feat: Add website.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 30, 2020
1 parent 674a04d commit 88cffbc
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
node-version: 12
registry-url: https://registry.npmjs.org/


- run: npm run start
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

Chrome 插件 [oscnews](https://github.com/jaywcjlove/oscnews) 的子仓库,存储网址导航 logo 的仓库。

预览所有 logo 图标:http://jaywcjlove.github.io/logo/

## Chrome插件

Expand Down
77 changes: 77 additions & 0 deletions create.js
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 `
)
})();
56 changes: 56 additions & 0 deletions img/index.html

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
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"
}
}

0 comments on commit 88cffbc

Please sign in to comment.