-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-thumbnail-demo-page.ts
75 lines (64 loc) · 1.23 KB
/
create-thumbnail-demo-page.ts
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
71
72
73
74
75
import * as glob from 'npm:glob';
import { parse } from "https://deno.land/std/flags/mod.ts";
const { inDir, outFile } = parse(Deno.args)
if(!inDir)
throw new Error('inDir is required');
const thumbnailPaths = await glob.glob('**/*.{jpg,jpeg,png,svg}', {
cwd: inDir,
absolute: true
});
const itemTemplate = (path) => `
<li>
<a href="${path}">
${path}
</a>
<img src="${path}" />
</li>
`;
const HTML = `
<html>
<head>
<title>Thumbnails</title>
<style>
body {
margin: 0;
padding: 0;
}
.thumbs {
display: flex;
flex-wrap: wrap;
ul {
list-style: none;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
flex-basis: 33%;
li {
margin: 10px;
padding: 0;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 5px #ccc;
width: 100%;
}
}
}
</style>
</head>
<body>
<div class="thumbs">
<ul>
${thumbnailPaths.map(itemTemplate).join('')}</div>
</ul>
</body>
</html>
`;
if (outFile){
Deno.writeTextFile(
outFile,
HTML
);
Deno.exit();
}
console.log(HTML)