Skip to content

Instantly share code, notes, and snippets.

@min50250
Last active September 17, 2023 16:09
Show Gist options
  • Save min50250/45e9504edce63d9afa0d4e17ce198377 to your computer and use it in GitHub Desktop.
Save min50250/45e9504edce63d9afa0d4e17ce198377 to your computer and use it in GitHub Desktop.
Step4. 키워드 테이블 만들기
/* 키워드와 키워드 중복 수로 만들어진 테이블 만들기
```dataviewjs */
let html = ""
let keywords = dv.current().file.outlinks.values.filter(link => link.display.startsWith(')')).map(link => link.display)
keywords = keywords.filter(p => !p.includes(dv.current().file.name))
console.log(countDuplicates(keywords))
function countDuplicates(array) {
const counts = {};
const result = [];
// 중복된 요소의 개수를 세기
array.forEach((item) => {
counts[item] = (counts[item] || 0) + 1;
});
// 중복이 제거된 2차원 배열 생성
for (const key in counts) {
result.push([key, counts[key]]);
}
// 중복 개수에 따라 내림차순으로 정렬
result.sort((a, b) => b[1] - a[1]);
return result;
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment