starter code
This commit is contained in:
parent
b15148ca19
commit
17bfc2a6d0
@ -10,10 +10,9 @@ export const load: PageServerLoad = async () => {
|
|||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
createArticle: async ({ request }) => {
|
createArticle: async ({ request }) => {
|
||||||
const { title, content } = Object.fromEntries(await request.formData()) as {
|
const { title, content } = Object.fromEntries(
|
||||||
title: string
|
await request.formData(),
|
||||||
content: string
|
) as Record<string, string>
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await prisma.article.create({
|
await prisma.article.create({
|
||||||
|
@ -22,10 +22,9 @@ export const load: PageServerLoad = async ({ params }) => {
|
|||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
updateArticle: async ({ request, params }) => {
|
updateArticle: async ({ request, params }) => {
|
||||||
const { title, content } = Object.fromEntries(await request.formData()) as {
|
const { title, content } = Object.fromEntries(
|
||||||
title: string
|
await request.formData(),
|
||||||
content: string
|
) as Record<string, string>
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await prisma.article.update({
|
await prisma.article.update({
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<form>
|
<form method="POST">
|
||||||
<hgroup>
|
<hgroup>
|
||||||
<h2>Login</h2>
|
<h2>Login</h2>
|
||||||
<h3>Welcome back!</h3>
|
<h3>Welcome back!</h3>
|
||||||
</hgroup>
|
</hgroup>
|
||||||
<label for="email">Email address</label>
|
<label for="username">Username</label>
|
||||||
<input type="email" id="email" name="email" required />
|
<input type="text" id="username" name="username" required />
|
||||||
|
|
||||||
<label for="email">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="email" id="email" name="password" required />
|
<input type="password" id="password" name="password" required />
|
||||||
|
|
||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -1,25 +1,17 @@
|
|||||||
<form>
|
<form method="POST">
|
||||||
<hgroup>
|
<hgroup>
|
||||||
<h2>Register</h2>
|
<h2>Register</h2>
|
||||||
<h3>To post articles, you'll need an account.</h3>
|
<h3>To post articles, you'll need an account.</h3>
|
||||||
</hgroup>
|
</hgroup>
|
||||||
<div class="grid">
|
|
||||||
<label for="firstname">
|
|
||||||
First name
|
|
||||||
<input type="text" id="firstname" name="firstname" required />
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label for="lastname">
|
<label for="name">Name</label>
|
||||||
Last name
|
<input type="text" id="name" name="name" required />
|
||||||
<input type="text" id="lastname" name="lastname" required />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label for="email">Email address</label>
|
<label for="username">Username</label>
|
||||||
<input type="email" id="email" name="email" required />
|
<input type="text" id="username" name="username" required />
|
||||||
|
|
||||||
<label for="email">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="email" id="email" name="password" required />
|
<input type="password" id="password" name="password" required />
|
||||||
|
|
||||||
<button type="submit">Register</button>
|
<button type="submit">Register</button>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user