Created
October 27, 2022 23:57
-
-
Save tatsuyasusukida/29187a0ebaa753896e67fab34bdca540 to your computer and use it in GitHub Desktop.
How to generate member list with TypeScript
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
薄田 達哉 | |
すすきだ たつや | |
株式会社ロレムイプサム 代表取締役 | |
susukida.jpg | |
1987年生まれ、北海道出身、新潟県在住のプログラマー。 | |
苫小牧高専と長岡技術科学大学で情報工学を学び、2011年に株式会社ロレムイプサムを設立。 | |
事業内容はアプリ開発とWebサイト制作。 | |
2020年に技術書籍「図解即戦力 仮想化&コンテナがこれ1冊でしっかりわかる教科書」(技術評論社)を共著。 | |
こんなことお手伝いできます! | |
アプリ開発 | |
Webサイト制作 | |
ここに氏名が入ります | |
ここにフリガナが入ります | |
ここに所属が入ります | |
profile.jpg | |
ここに自己紹介が入ります。 | |
ここに自己紹介が入ります。 | |
ここに自己紹介が入ります。 | |
ここに自己紹介が入ります。 | |
ここに自己紹介が入ります。 | |
ここに見出しが入ります | |
ここに項目が入ります | |
ここに項目が入ります | |
ここに項目が入ります |
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
import { readFileSync, writeFileSync } from "fs"; | |
import Mustache from "mustache"; | |
function main() { | |
const text = readFileSync("input.txt", "utf-8"); | |
const members = text.split("\n\n\n\n").map((str) => { | |
const pieces = str.split("\n\n"); | |
const [name, kana, title, image] = pieces[0].split("\n"); | |
const text = pieces[1].split("\n").join(''); | |
const header = pieces[2]; | |
const items = pieces[3].split("\n").map((line) => ({ line })); | |
return { name, kana, title, image, text, header, items }; | |
}); | |
const template = readFileSync("template.html", "utf-8"); | |
const html = Mustache.render(template, { members }); | |
writeFileSync("output.html", html); | |
} | |
main(); |
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
@page { | |
margin: 15mm 15mm 15mm 15mm; | |
} | |
html { | |
font-size: 10.5pt; | |
font-family: serif; | |
} | |
h1 { | |
font-size: 18pt; | |
margin: 0 0 1rem; | |
} | |
h2 { | |
font-size: 14pt; | |
margin: 0 0 1rem; | |
} | |
h3 { | |
font-size: 12pt; | |
margin: 0 0 1rem; | |
} | |
p { | |
margin: 0 0 1rem; | |
} | |
ul { | |
list-style: none; | |
padding: 0; | |
margin: 0 0 1rem; | |
} | |
li { | |
display: inline; | |
} | |
li::before { | |
content: "/"; | |
} | |
li:first-child:before { | |
content: ""; | |
} | |
img { | |
max-width: 100%; | |
border-radius: 50%; | |
border: 1pt solid #cccccc; | |
} | |
.row { | |
display: flex; | |
gap: 1.5rem; | |
} | |
.col { | |
flex: 1; | |
} | |
.col.is-image { | |
flex: 0.18; | |
} |
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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>メンバー紹介</title> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<h1>メンバー紹介</h1> | |
{{#members}} | |
<section> | |
<h2>{{name}} | {{kana}}</h2> | |
<div class="row"> | |
<div class="col is-image"> | |
<img src="img/{{image}}" alt=""> | |
</div> | |
<div class="col"> | |
<p>{{text}}</p> | |
<section> | |
<h3>{{header}}</h3> | |
<ul> | |
{{#items}} | |
<li>{{line}}</li> | |
{{/items}} | |
</ul> | |
</section> | |
</div> | |
</div> | |
</section> | |
{{/members}} | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment