-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemantic_markup.api.php
106 lines (106 loc) · 3.25 KB
/
semantic_markup.api.php
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* hook_semantic_markup_mappings().
*
* Provides RDFa xpath mappings.
*/
function hook_semantic_markup_mappings() {
$node_base = "//*[contains(concat(' ', @class, ' '), ' node-full ')]";
$rdfa_mappings = array(
// Global example using the vocab attribute.
array(
'type' => 'global',
'mappings' => array(
array(
'xpath' => "//*[contains(concat(' ', @class, ' '), ' logo-wrapper ')]",
'attributes' => array(
'vocab' => 'http://schema.org/',
'typeof' => 'Organization',
),
),
array(
'xpath' => "//a[contains(concat(' ', @class, ' '), ' site-logo ')]",
'attributes' => array(
'property' => 'url',
),
),
array(
'xpath' => "//a[contains(concat(' ', @class, ' '), ' site-logo ')]//img",
'attributes' => array(
'property' => 'logo',
),
),
),
),
// Node example using a prefix, useful when mixing vocabularies.
array(
'type' => 'node',
'bundle' => 'article',
'mappings' => array(
array(
'xpath' => "//*[@id='page']",
'attributes' => array(
'prefix' => 'schema:http://schema.org/',
),
),
array(
'xpath' => "//*[@id='main']",
'attributes' => array(
'typeof' => 'schema:Article',
),
),
array(
'xpath' => "//h1",
'attributes' => array(
'property' => 'schema:headline',
),
),
array(
'xpath' => "//h1",
'element' => 'span',
'position' => 'after',
'attributes' => array(
'property' => 'schema:alternativeHeadline',
'content' => '[node:title]',
),
),
array(
'xpath' => $node_base . "//*[contains(concat(' ', @class, ' '), ' field-name-field-author ')]",
'attributes' => array(
'typeof' => 'schema:Person',
'property' => 'schema:author',
),
),
array(
'xpath' => $node_base . "//*[contains(concat(' ', @class, ' '), ' field-name-field-author ')]//*[contains(concat(' ', @class, ' '), ' field-item ')]",
'attributes' => array(
'property' => 'schema:name',
),
),
array(
'xpath' => $node_base . "//*[contains(concat(' ', @class, ' '), ' field-name-field-published-date ')]//*[contains(concat(' ', @class, ' '), ' date-display-single ')]",
'attributes' => array(
'property' => 'schema:datePublished',
'content' => array(
'value' => '[node:field-published-date:raw]',
'callback' => 'date_iso8601',
),
),
),
array(
'xpath' => $node_base . "//*[contains(concat(' ', @class, ' '), ' field-name-body ')]",
'attributes' => array(
'property' => 'schema:articleBody',
),
),
array(
'xpath' => $node_base . "//*[contains(concat(' ', @class, ' '), ' primary-image ')]/img",
'attributes' => array(
'property' => 'schema:image',
),
),
),
),
);
return $rdfa_mappings;
}