Skip to content

Commit

Permalink
Merge pull request #55 from ansxor/blog-permalink
Browse files Browse the repository at this point in the history
Blog permalink
  • Loading branch information
12Me21 authored Dec 26, 2024
2 parents 2588af5 + 9a0f23c commit d12c7c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Views/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PageView extends BaseView {
},
requests: [
{type: 'content', fields: "*", query: `${field} = @key`},
{name: 'Pcontent', type: 'content', fields: "*", query: `id = @content.parentId`},
{type: 'message', fields: "*", query: "contentId IN @content.id AND !notdeleted()", order: 'id_desc', limit: 30},
{name: 'Mpinned', type: 'message', fields: "*", query: "id IN @content.values.pinned"},
{type: 'user', fields: "*", query: "id IN @content.createUserId OR id IN @message.createUserId OR id IN @message.editUserId OR id IN @Mpinned.createUserId OR id IN @Mpinned.editUserId"},
Expand Down Expand Up @@ -90,7 +91,7 @@ class PageView extends BaseView {
}
})
}
Render({message, content:[page], Mpinned:pinned, user, watch}) {
Render({message, content:[page], Mpinned:pinned, user, watch, Pcontent:[parent]}) {
this.page_id = page.id

// header //
Expand All @@ -100,6 +101,21 @@ class PageView extends BaseView {
{icon:"✏️", label:"edit", href:"#editpage/"+page.id},
{icon:"🗂️", label:"childs", href:"#category/"+page.id},
])

if (!OPTS.has('dev')) {
const domain = Req.server.split("/")[0]
let href = undefined
if (page.values.share) {
href = `https://${domain}/share/${page.hash}`;
} else if (parent?.values.share && parent?.literalType==="resource") {
href = `https://${domain}/share/${parent.hash}/${page.hash}`;
}
if (href) {
this.Slot.add_header_links([
{icon:"🌐", label:"blog", href, target: "_blank"}
])
}
}

// init components //
Object.assign(Lp.users, user)
Expand Down
1 change: 1 addition & 0 deletions src/navigate.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ViewSlot {
for (let x of items) {
let a = document.createElement('a')
a.href = x.href
a.target = x['target'] || '_self'
let lb = document.createElement('span')
lb.textContent = x.label
a.append(lb)
Expand Down

0 comments on commit d12c7c6

Please sign in to comment.