Add data-is-primary attribute to headwords (#1946)
This commit is contained in:
parent
6661933d47
commit
88e71f8223
@ -232,12 +232,21 @@ class DisplayGenerator {
|
|||||||
// Private
|
// Private
|
||||||
|
|
||||||
_createTermHeadword(headword, headwordIndex, pronunciations) {
|
_createTermHeadword(headword, headwordIndex, pronunciations) {
|
||||||
const {term, reading, tags} = headword;
|
const {term, reading, tags, sources} = headword;
|
||||||
|
|
||||||
|
let isPrimaryAny = false;
|
||||||
|
for (const {isPrimary} of sources) {
|
||||||
|
if (isPrimary) {
|
||||||
|
isPrimaryAny = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const node = this._templates.instantiate('headword');
|
const node = this._templates.instantiate('headword');
|
||||||
|
|
||||||
const termContainer = node.querySelector('.headword-term');
|
const termContainer = node.querySelector('.headword-term');
|
||||||
|
|
||||||
|
node.dataset.isPrimary = `${isPrimaryAny}`;
|
||||||
node.dataset.readingIsSame = `${reading === term}`;
|
node.dataset.readingIsSame = `${reading === term}`;
|
||||||
node.dataset.frequency = DictionaryDataUtil.getTermFrequency(tags);
|
node.dataset.frequency = DictionaryDataUtil.getTermFrequency(tags);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user