Skip to content

Commit 9e12850

Browse files
authored
Merge pull request #1 from andrewpap22/apappas/add-head-title-description-clear-error-msgs
Adds head tag, title, meta tag description, clears useState error msgs on appropriate input chars
2 parents e2c13ab + f134793 commit 9e12850

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/pages/index.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import clsx from "clsx";
55
import AuthButtons, { LogOutButton } from "../components/authButtons";
66
import { useState } from "react";
77
import { trpc } from "../utils/trpc";
8+
import Head from "next/head";
89

910
/// component to get all messages using react-query
1011
const Messages = () => {
@@ -31,7 +32,7 @@ const Messages = () => {
3132
<span className="text-gray-500">
3233
- <span className="text-gray-300">{msg.name}</span> &nbsp; /
3334
&nbsp; {msg.createdAt.toString().split(" ").slice(0, 5).join(" ")}{" "}
34-
{/** .split... remove the GMT ... from the outputted string */}
35+
{/** .split... removes the GMT ... from the outputted string */}
3536
</span>
3637
</div>
3738
);
@@ -58,7 +59,7 @@ const Home = () => {
5859
onMutate: () => {
5960
ctx.cancelQuery(["guestbook.getAllMessagesAndNames"]);
6061

61-
let optimisticUpdate = ctx.getQueryData([
62+
const optimisticUpdate = ctx.getQueryData([
6263
"guestbook.getAllMessagesAndNames",
6364
]);
6465
if (optimisticUpdate) {
@@ -88,11 +89,13 @@ const Home = () => {
8889
return;
8990
}
9091

92+
/// when the message is < 100 && > 0 characters, we can post it and clear the error messages
9193
postMessage.mutate({
9294
name: session?.user?.name as string,
9395
message,
9496
});
9597

98+
setError("");
9699
setMessage("");
97100
setLoading(false);
98101
console.log("refetched!");
@@ -108,6 +111,11 @@ const Home = () => {
108111

109112
return (
110113
<>
114+
<Head>
115+
<title>A.Pappas - Guestbook</title>
116+
<meta name="description" content="Sign the andreaspappas.xyz guestbook and leave a message for a future visitor of my site!" />
117+
</Head>
118+
111119
<header>
112120
<h1 className="text-3xl pt-4 pb-2 flex flex-col items-center">
113121
🦁 andreaspappas.xyz - Guestbook

0 commit comments

Comments
 (0)