-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposts.11tydata.js
79 lines (68 loc) · 2.23 KB
/
posts.11tydata.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const { parseHTML } = require('linkedom')
module.exports = {
layout: 'digest',
tags: ['aroundTheWeb'],
['override:pageCSS']: ['around-the-web', 'text-page'],
eleventyComputed: {
meta: function (data) {
return {
description: data.intro,
image: {
src: `${data.site.baseURL}/img/around-the-web/${data.page.fileSlug}-og.jpg`,
alt: 'A library in Prague. The ceiling is decorated with magnificent frescoes. The shelfes are old, you can smell the history contained in these books, it oozes from the picture. Written on top are the words «Around the web».',
},
ogType: 'article',
ogImageType: 'image/jpg',
}
},
parsedDates: function (data) {
return {
start: new Date(data.dates.start),
publish: this.setPublishDate(new Date(data.dates.publish)),
}
},
pageTitle: function (data) {
const { start, publish } = data.parsedDates
if (start && publish) {
let title = `${this.displayDate(start, 'short')}–${this.displayDate(
publish,
'short',
)}`
if (data.issueTitle) {
title = data.issueTitle
}
return `${title} | Around the Web`.trim()
}
},
title: ({ issueTitle }) => issueTitle || 'Around the Web',
permalink: function (data) {
if (data.issueTitle) {
return `/around-the-web/${data.page.fileSlug}-${this.slugify(
data.issueTitle,
)}/`
}
return `/around-the-web/${data.page.fileSlug}/`
},
sources: async function (data) {
if (!data.page) return
const rendered = await this.renderFile(data.page.inputPath)
const { document } = parseHTML(rendered)
const allLinks = document.querySelectorAll('a')
const sources = new Set()
for (const link of allLinks) {
// as i dont link to gopher anything without http is most likely a link to my own page
if (!link.href.startsWith('http')) {
sources.add(data.site.baseURL)
continue
}
sources.add(new URL(link.href).origin)
}
return {
links: [...allLinks],
count: allLinks.length,
sources,
distinct: sources.size,
}
},
},
}