Skip to content

Commit

Permalink
add <head> meta imagery to posts
Browse files Browse the repository at this point in the history
  • Loading branch information
traceypooh committed Jul 8, 2024
1 parent e438cbe commit 5a74254
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/blogtini.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: blogtini.com lightweight build & deploy to GitHub Pages
# push:
# branches: ["main"]
#jobs:
# cicd:
# blogtini:
# uses: traceypooh/blogtini/.github/workflows/blogtini.yml@main


Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ on:
push:
branches: ["main"]
jobs:
cicd:
blogtini:
uses: traceypooh/blogtini/.github/workflows/blogtini.yml@main
10 changes: 8 additions & 2 deletions js/blogtini.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ function storage_loop() {
// eslint-disable-next-line no-use-before-define
head_insert_json_ld(post)
// eslint-disable-next-line no-use-before-define
head_insert_titles(post.title)
head_insert_titles(post.title, imgurl(post, true, false))
state.filter_post_url = urlify(post.url)
} else if (filter_tag.length) {
// eslint-disable-next-line no-use-before-define
Expand Down Expand Up @@ -818,7 +818,7 @@ function imgurl(post, nohash = true, relative = false) {
return nohash ? img.replace(/#(bottom|top)$/, '') : img
}

function head_insert_titles(title) {
function head_insert_titles(title, img) {
document.title = title // xxx &gt; &lt;

// document.getElementsByTagName('meta')['description'].content = 'New meta description'
Expand All @@ -842,6 +842,12 @@ function head_insert_titles(title) {
e.setAttribute('content', title) // xxx quote escape, etc.
document.head.appendChild(e)
}
if (img) {
const e = document.createElement('meta') // chexxx
e.setAttribute('property', 'og:image')
e.setAttribute('content', img) // xxx quote escape, etc.
document.head.appendChild(e)
}
}

function head_insert_json_ld(post) {
Expand Down

0 comments on commit 5a74254

Please sign in to comment.