-
Notifications
You must be signed in to change notification settings - Fork 3
/
metadata.js
executable file
·68 lines (51 loc) · 1.88 KB
/
metadata.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
const fs = require('fs');
//const appRoot = require('app-root-path').path; // fails when the eleventy package is linked (edge case)
const glob = require('fast-glob');
// find nearest package.json
function findNearestPackageDir() {
const dirs = __dirname.split('/');
while (dirs.length > 0) {
const d = dirs.join('/');
const f = d + '/package.json';
if (fs.existsSync(f)) return d;
dirs.pop();
}
}
const appRoot = findNearestPackageDir();
// use last modify-time as version
const version = glob.sync(appRoot + '/src/pages/page-*.html')
.map(file => ({ file, mtime: fs.statSync(file).mtime }))
.sort((a, b) => (b.mtime - a.mtime)) // sort descending
[0]
.mtime
.toLocaleDateString('af')
;
console.log(`metadata.js: version = ${version}`)
const metadata = {};
metadata.languages = "en es de tr ru ar fa cs ro hu zh"; // TODO add new languages here
metadata.defaultLanguage = "en";
metadata.primarylanguage = metadata.defaultLanguage; // TODO rename to defaultLanguage
// TODO translate
metadata.basename = {};
metadata.basename.de = "alchi-book";
metadata.iconSvgPath = "alchi-pallas-symbol.small.svg";
metadata.title = "Your Blog Name"; // TODO
metadata.version = version;
metadata.url = "https://example.com/";
// TODO SEO
metadata.description = "description"; // TODO
metadata.keywords = "keywords"; // TODO
metadata.feed = {};
metadata.feed.subtitle = "I am writing about my experiences as a naval navel-gazer.";
metadata.feed.filename = "feed.xml";
metadata.feed.path = "/feed/feed.xml";
metadata.feed.id = "https://example.com/";
metadata.jsonfeed = {};
metadata.jsonfeed.path = "/feed/feed.json";
metadata.jsonfeed.url = "https://example.com/feed/feed.json";
metadata.author = {};
metadata.author.name = "Milan Hauth";
metadata.author.email = "milahu@gmail.com";
metadata.author.url = "https://github.com/milahu";
//export default metadata;
module.exports = metadata;