mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
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:
@@ -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>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user