-
Notifications
You must be signed in to change notification settings - Fork 0
/
ogp-image-template.html
70 lines (64 loc) · 1.15 KB
/
ogp-image-template.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>OGP画像自動生成君</title>
<style>
html {
background: #00cccc;
color: #ffffff;
font-family: sans-serif;
}
body {
margin: 0;
padding: 4vw;
}
.title-wrapper {
display: flex;
justify-content: center;
align-items: center;
height: 80vh;
font-size: 72px;
}
.title {
margin: 0;
font-family: "dnp-shuei-anti-std", sans-serif;
font-weight: bold;
font-feature-settings: "palt";
line-height: 1.2;
text-align: center;
}
</style>
</head>
<body>
<div class="title-wrapper">
<h1 class="title">記事タイトル</h1>
</div>
<script src="https://use.typekit.net/dcq8piw.js"></script>
<script>
document.addEventListener("DOMContentLoaded", () => {
try {
Typekit.load({
active: () => {
draw();
}
});
} catch (e) {
}
});
async function draw() {
const props = await getProps();
const title = document.querySelectorAll(".title")[0];
title.textContent = props.title;
let fontSize = 100;
for (; ;) {
title.style.fontSize = fontSize + "px";
if (title.offsetHeight <= window.innerHeight * 0.8) {
break;
}
fontSize -= 1;
}
}
</script>
</body>
</html>