Skip to content

Commit

Permalink
get comments working for sites located in subdirs
Browse files Browse the repository at this point in the history
  • Loading branch information
traceypooh committed Jan 30, 2025
1 parent 5ffe6e4 commit 18241ca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion theme/future-imperfect/bt-post-full.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ customElements.define('bt-post-full', class extends LitElement {
const post = url2post(this.url)
const body = markdown_to_html(post.body_raw)

// remove site_url prefix in case posts are 1+ subdir deep, example site & post:
// https://traceypooh.github.io/poohtini/
// https://traceypooh.github.io/poohtini/2024-04-sedona-death-valley-grand-canyon/
// use a default base in case url is relative (pathname) only
const comments_entryid = new URL(post.url, 'https://blogtini.com').pathname.replace(/^\/+/, '').replace(/\/+$/, '') // xxx
const relative_path = post.url.startsWith(cfg.site_url)
? post.url.slice(cfg.site_url.length)
: post.url
// ensure is just path. remove lead/trail / chars
const comments_entryid = new URL(relative_path, 'https://blogtini.com').pathname.replace(/^\/+/, '').replace(/\/+$/, '')

const socnet_share = share_buttons(post)

Expand Down

0 comments on commit 18241ca

Please sign in to comment.