-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.html
87 lines (69 loc) · 2.51 KB
/
create.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
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>markdown editor/creator</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;600&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="src/css/main.css">
<style>
* {
box-sizing: border-box;
}
form {
margin: 20px;
}
input, textarea, button {
font: 14px "Space Grotesk";
width: 100%;
margin-bottom: 10px;
}
textarea {
height: 10rem;
}
</style>
</head>
<body style="overflow-y: auto;">
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.1/showdown.min.js" integrity="sha512-L03kznCrNOfVxOUovR6ESfCz9Gfny7gihUX/huVbQB9zjODtYpxaVtIaAkpetoiyV2eqWbvxMH9fiSv5enX7bw==" crossorigin="anonymous"></script>
<form>
<label for="title">Title</label><br />
<input type="text" name="title" placeholder="Title" size="100"><br />
<label for="description">Description</label><br />
<input type="text" name="description" placeholder="Description" size="100"><br />
<label for="description">Tags</label><br />
<input type="text" name="tags" placeholder="Tags" size="100"><br />
<label for="markdownText">Type markdown text</label><br />
<textarea name="markdownText"></textarea><br />
<button onclick="
event.preventDefault();
const mdToHtml = new showdown.Converter();
const content = document.forms[0].markdownText.value;
let post = {
_id: makeid(20),
title: document.forms[0].title.value,
description: document.forms[0].description.value,
date: new Date().toLocaleString('id'),
tags: document.forms[0].tags.value.split(', '),
content: content,
htmlContent: mdToHtml.makeHtml(content)
};
document.querySelector('#result').innerHTML = post;
console.log(post);
">submit</button>
</form>
<div id="result"></div>
<script>
function makeid(length) {
var result = '';
var characters = '1234567890abcdef';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
</script>
</body>
</html>