Skip to content

Commit

Permalink
Fix canonical url bug and update default values
Browse files Browse the repository at this point in the history
  • Loading branch information
NiallJoeMaher committed Jan 6, 2024
1 parent fa61d64 commit 0354a74
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/articles/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {

const post = await getPost({ slug });

// Might revisit to give more defaults
// @TODO revisit to give more defaults
const tags = post?.tags.map((tag) => tag.tag.title);

if (!post) return {};
Expand Down
6 changes: 4 additions & 2 deletions app/create/[[...paramsArr]]/_client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Create = () => {
usePrompt();

useEffect(() => {
_setUnsaved(unsavedChanges);
_setUnsaved();
}, [unsavedChanges, _setUnsaved]);

const allowUpdate = unsavedChanges;
Expand Down Expand Up @@ -350,7 +350,9 @@ const Create = () => {
id="canonicalUrl"
type="text"
placeholder="https://www.somesite.com/i-posted-here-first"
defaultValue=""
defaultValue={
data?.canonicalUrl ? data.canonicalUrl : ""
}
{...register("canonicalUrl")}
/>
<p className="mt-2 text-sm text-neutral-600 dark:text-neutral-400">
Expand Down
2 changes: 1 addition & 1 deletion server/api/router/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const postRouter = createTRPCRouter({
title,
excerpt: getExcerptValue() || "",
readTimeMins: readingTime(body),
canonicalUrl,
canonicalUrl: !!canonicalUrl ? canonicalUrl : null,
},
});
return post;
Expand Down

0 comments on commit 0354a74

Please sign in to comment.