~cadence/bibliogram

ref: d660c849411808d12f8ab75beac87d633491c6e2 bibliogram/src/site/pug/post.pug -rw-r--r-- 2.0 KiB
d660c849Cadence Ember Fix shortcode fetching 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//- Needs website_origin, title, post, settings

- const ll = lang.get(settings.language)

include includes/post

doctype html
html
	head
		title= title
		include includes/head
		if settings.spa
			script(type="module" src=getStaticURL("html", "/static/js/post_overlay.js"))
		meta(property="og:url" content=`${website_origin}/p/${post.data.shortcode}`)
		meta(property="og:type" content="article")
		- let firstEntry = post.children[0]
		- let postType = "Photo"
		if post.children.length >= 2
			- postType = "Post" //- it's a gallery, but "Gallery" doesn't really sound right
		else if firstEntry.isVideo()
			- postType = "Video"
		meta(property="og:title" content=`${postType} by ${post.data.owner.full_name || post.data.owner.username}`)
		- let description = ""
		if post.getCaption()
			- description = post.getCaption()
		if post.children.length >= 2
			if description
				- description = `\n\n${description}`
			- let galleryType = post.children.every(c => c.isVideo()) ? "videos" : "images"
			- description = `Gallery of ${post.children.length} ${galleryType}.${description}`
		if description
			meta(property="og:description" content=description)
		if firstEntry.isVideo()
			meta(property="og:video" content=`${website_origin}${firstEntry.getVideoUrlP()}`)
			meta(property="og:video:type" content="video/mp4")
			meta(property="og:video:width" content=firstEntry.data.dimensions.width)
			meta(property="og:video:height" content=firstEntry.data.dimensions.height)
			meta(property="og:video:alt" content=firstEntry.getAlt())
		else
			meta(property="og:image" content=`${website_origin}${firstEntry.getDisplayUrlP()}`)
			meta(property="og:image:width" content=firstEntry.data.dimensions.width)
			meta(property="og:image:height" content=firstEntry.data.dimensions.height)
			meta(property="og:image:type" content="image/jpeg")
			meta(property="og:image:alt" content=firstEntry.getAlt())
		meta(property="og:site_name" content="Bibliogram")

	body.post-page
		main
			+post(post, false)