fix: broken editPost link and update editPost logic (#487)

* fix: broken editPost link and update editPost logic

Fixed broken editPost link. Removed the ability to update
the editPost link inside each blog post for consistency.
The editPost button per blog post can still be hidden.

* docs: update docs for editPost
This commit is contained in:
Sat Naing
2025-03-20 12:41:58 +07:00
committed by GitHub
parent 48f200f444
commit 2774045045
6 changed files with 22 additions and 31 deletions
+10 -13
View File
@@ -4,21 +4,16 @@ import IconEdit from "@/assets/icons/IconEdit.svg";
import { SITE } from "@/config";
export interface Props {
editPost?: CollectionEntry<"blog">["data"]["editPost"];
postId?: CollectionEntry<"blog">["id"];
hideEditPost?: CollectionEntry<"blog">["data"]["hideEditPost"];
class?: string;
post: CollectionEntry<"blog">;
}
const { editPost, postId, class: className = "" } = Astro.props;
const { hideEditPost, post, class: className = "" } = Astro.props;
let editPostUrl = editPost?.url ?? SITE?.editPost?.url ?? "";
const showEditPost = !editPost?.disabled && editPostUrl.length > 0;
const appendFilePath =
editPost?.appendFilePath ?? SITE?.editPost?.appendFilePath ?? false;
if (appendFilePath && postId) {
editPostUrl += `/${postId}`;
}
const editPostText = editPost?.text ?? SITE?.editPost?.text ?? "Edit";
const href = `${SITE.editPost.url}${post.filePath}`;
const showEditPost =
SITE.editPost.enabled && !hideEditPost && href.trim() !== "";
---
{
@@ -29,12 +24,14 @@ const editPostText = editPost?.text ?? SITE?.editPost?.text ?? "Edit";
</span>
<a
class="space-x-1.5 hover:opacity-75"
href={editPostUrl}
href={href}
rel="noopener noreferrer"
target="_blank"
>
<IconEdit class="inline-block size-6" />
<span class="italic max-sm:text-sm sm:inline">{editPostText}</span>
<span class="italic max-sm:text-sm sm:inline">
{SITE.editPost.text}
</span>
</a>
</div>
)