✨ Changeable permalink
This commit is contained in:
parent
a223c85ed1
commit
4dbbb423e7
@ -13,12 +13,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func getPost(c *fiber.Ctx) error {
|
func getPost(c *fiber.Ctx) error {
|
||||||
id, _ := c.ParamsInt("postId", 0)
|
id := c.Params("postId")
|
||||||
take := c.QueryInt("take", 0)
|
take := c.QueryInt("take", 0)
|
||||||
offset := c.QueryInt("offset", 0)
|
offset := c.QueryInt("offset", 0)
|
||||||
|
|
||||||
tx := database.C.Where(&models.Post{
|
tx := database.C.Where(&models.Post{
|
||||||
BaseModel: models.BaseModel{ID: uint(id)},
|
Alias: id,
|
||||||
})
|
})
|
||||||
|
|
||||||
post, err := services.GetPost(tx)
|
post, err := services.GetPost(tx)
|
||||||
|
@ -69,7 +69,7 @@ export default function PostItem(props: {
|
|||||||
<div class="px-7 py-5">
|
<div class="px-7 py-5">
|
||||||
<h2 class="card-title">{props.post.title}</h2>
|
<h2 class="card-title">{props.post.title}</h2>
|
||||||
<Show when={!props.noClick} fallback={content}>
|
<Show when={!props.noClick} fallback={content}>
|
||||||
<a href={`/posts/${props.post.id}`}>
|
<a href={`/posts/${props.post.alias}`}>
|
||||||
{content}
|
{content}
|
||||||
</a>
|
</a>
|
||||||
</Show>
|
</Show>
|
||||||
|
@ -261,6 +261,9 @@ export default function PostPublish(props: {
|
|||||||
|
|
||||||
<div id="publish-actions" class="flex justify-between border-y border-base-200">
|
<div id="publish-actions" class="flex justify-between border-y border-base-200">
|
||||||
<div class="flex pl-[20px]">
|
<div class="flex pl-[20px]">
|
||||||
|
<button type="button" class="btn btn-ghost w-12" onClick={() => openModel("#alias")}>
|
||||||
|
<i class="fa-solid fa-link"></i>
|
||||||
|
</button>
|
||||||
<button type="button" class="btn btn-ghost w-12" onClick={() => openModel("#attachments")}>
|
<button type="button" class="btn btn-ghost w-12" onClick={() => openModel("#attachments")}>
|
||||||
<i class="fa-solid fa-paperclip"></i>
|
<i class="fa-solid fa-paperclip"></i>
|
||||||
</button>
|
</button>
|
||||||
@ -281,6 +284,26 @@ export default function PostPublish(props: {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<dialog id="alias" class="modal">
|
||||||
|
<div class="modal-box">
|
||||||
|
<h3 class="font-bold text-lg mx-1">Permalink</h3>
|
||||||
|
<label class="form-control w-full mt-3">
|
||||||
|
<div class="label">
|
||||||
|
<span class="label-text">Alias</span>
|
||||||
|
</div>
|
||||||
|
<input name="alias" type="text" placeholder="Type here" class="input input-bordered w-full" />
|
||||||
|
<div class="label">
|
||||||
|
<span class="label-text-alt">
|
||||||
|
Leave blank to generate a random string.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<div class="modal-action">
|
||||||
|
<button type="button" class="btn" onClick={() => closeModel("#alias")}>Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
<dialog id="planning-publish" class="modal">
|
<dialog id="planning-publish" class="modal">
|
||||||
<div class="modal-box">
|
<div class="modal-box">
|
||||||
<h3 class="font-bold text-lg mx-1">Planning Publish</h3>
|
<h3 class="font-bold text-lg mx-1">Planning Publish</h3>
|
||||||
|
Loading…
Reference in New Issue
Block a user