-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
78 lines (72 loc) · 2.83 KB
/
index.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
71
72
73
74
75
76
77
78
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>notebook</title>
<script id="React" src="https://cdn.bootcss.com/react/16.8.6/umd/react.development.js"></script>
<script id="ReactDom" src="https://cdn.bootcss.com/react-dom/16.8.6/umd/react-dom.development.js"></script>
<script id="Babel" src="https://cdn.bootcss.com/babel-standalone/6.26.0/babel.js"></script>
<link rel="stylesheet" href="./lib/style.css">
</head>
<body>
<div id="container"></div>
<script id="globalScript"></script>
<script type="text/babel" src="./lib/components.js"></script>
<script type="text/babel">
function App() {
return (
<div className="wrapper">
<Header />
<Section />
</div>
);
}
function Header() {
const { noteHtmlDir } = window;
const sources = {};
noteHtmlDir.forEach(noteObj => {
const { fileDirName, fileNames } = noteObj
const [year] = fileDirName.split('.');
if (sources[year]) {
sources[year].push(noteObj);
} else {
sources[year] = [noteObj];
}
});
return (
<header>
<div className="header-title">
<h1>n3taway</h1>
<p>notebook.</p>
</div>
<div className="header-nav">
{[Object.keys(sources)].map((year) => {
return <Button key={year}>{year}</Button>
})}
</div>
</header>
);
}
function Section() {
const { noteHtmlDir, location: { href } } = window;
return (
<section>
{noteHtmlDir.map((item, index) => {
return (
<div key={index} className="month-wrap">
<h1>{item.fileDirName.split('.')[1]}</h1>
{item.fileNames.map(fileName => {
return (
<div key={fileName}>
<a target="_blank" href={`${href}${item.fileDirName}/${fileName}`}>{fileName}</a>
</div>
)
})}
</div>
)
})}
</section>
);
}
ReactDOM.render(<App />, document.getElementById('container'));
</script>
</body></html>