forked from madnificent/tmp-frontend-semantic-works
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
50 lines (42 loc) · 1.4 KB
/
utils.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
export { inject as service } from '@ember/service';
import { set } from '@ember/object';
import config from './config/environment';
function parseTitle(title, forOpenGraph=false) {
if (typeof (title) == "string") {
title = [title];
}
title.push(config.meta.siteName);
if (!forOpenGraph) {
return title.join(" | ");
} else {
return `${title[0]} by ${config.meta.siteName}`;
}
}
export function setHeadData(
context,
title = [],
description=config.meta.description,
siteName=config.meta.siteName,
locale=config.meta.locale,
image="favicon.png",
origin=window.location.origin,
href=window.location.href.replace(window.location.search, "")
) {
set(context.headData, "type", "website");
set(context.headData, "title", parseTitle(title));
set(context.headData, "ogTitle", parseTitle(title, true));
set(context.headData, "description", description);
set(context.headData, "siteName", siteName);
set(context.headData, "locale", locale);
set(context.headData, "image", image);
set(context.headData, "origin", origin);
set(context.headData, "href", href);
//set(context.headData, "image", {{rootURL}});
}
/*
"ember-meta": {
description: "An open-source technology stack of re-usable, linked-data powered microservices",
url: "https://semantic.works/",
imgSrc: "{{rootURL}}/favicon.png",
},
*/