File tree Expand file tree Collapse file tree 4 files changed +28
-6
lines changed Expand file tree Collapse file tree 4 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -63,8 +63,23 @@ export async function getPeopleToFollow(state) {
63
63
// this is costly so we cache it
64
64
}
65
65
66
- export async function newPost ( state ) {
67
-
66
+ export async function newPost ( submitEvent , state ) {
67
+ const form = submitEvent . target ;
68
+ const Gist = g . getGist ( ) ;
69
+ const obj = {
70
+ description : form . description . value ,
71
+ public : true ,
72
+ files : {
73
+ [ 'post.md' ] : {
74
+ filename : 'post.md' ,
75
+ content : form . content . value
76
+ }
77
+ }
78
+ } ;
79
+ console . log ( { obj} ) ;
80
+ const gist = await Gist . create ( obj ) ;
81
+ form . reset ( ) ;
82
+ return gist ;
68
83
}
69
84
70
85
export function sortPostsByMostRecent ( posts ) {
Original file line number Diff line number Diff line change 1
1
import { R , X } from '../../node_modules/brutalist-web/r.js' ;
2
+ import { newPost } from '../api.js' ;
2
3
3
4
export default function NewPost ( state ) {
4
5
return R `${
5
6
showNewPost ( state ) ? R `
6
7
<div class=newpost>
7
8
<h1>${ state . currentFeed !== state . name ? "My feed" : "My posts" } </h1>
8
9
<article class="post view edit">
9
- <section class="post edit">
10
+ <form submit= ${ e => ( e . preventDefault ( ) , newPost ( e , state ) ) } action=#post class="post edit">
10
11
<p>
11
- <input name=tags placeholder=tags >
12
+ <input required name=description placeholder=description >
12
13
<p>
13
- <textarea name=post class="markdown live-mode" ></textarea>
14
+ <textarea required placeholder="What do you want to say?" name=content ></textarea>
14
15
<p>
15
16
<button class=post>Post</button>
16
17
</section>
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export default function Post(post) {
7
7
<ul>
8
8
${ Object . values ( post . files ) . map ( file => X `
9
9
<li>
10
- <header>${ file . filename } </header>
10
+ <header>${ file . filename !== 'post.md' ? file . filename : '' } </header>
11
11
<section class=content>
12
12
<pre>${ R . skip ( ( console . log ( file . content ) , file . content ) ) } </pre>
13
13
</section>
Original file line number Diff line number Diff line change 19
19
display : none;
20
20
}
21
21
22
+ article .post pre {
23
+ overflow-x : auto;
24
+ max-height : 200vh ;
25
+ overflow-y : auto;
26
+ }
27
+
22
28
/* general semantic grid areas */
23
29
.holygrail > header {
24
30
display : flex;
You can’t perform that action at this time.
0 commit comments