Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- hash table
- Bruth Force
- Python
- BFS
- Back tracking
- SWEA
- 코딩테스트
- Algorithm
- programmers
- Data Structure
- JavaScript
- 시뮬레이션
- spring boot
- Trie
- GitHub
- SQL
- boj
- 구현
- 알고리듬
- Vue.js
- CSV
- aws
- django
- Priority Queue
- 모의SW역량테스트
- DFS
- gpdb
- Linked list
- 알고리즘
- 코테
Archives
- Today
- Total
hotamul의 개발 이야기
[hotamul] github 댓글 기능 (utterances, Vue.js) 본문
share-blog 프로젝트는 협업 목적으로 만들고 있기 때문에 github과 연동해서 code 인용이나 참조를 쉽게 할 수 있어야 한다.
따라서 댓글 기능을 utterances를 이용해 구현했다.
...
<!-- Comments section-->
<div id="utte-comment" class="mb-5"></div>
...
원하는 위치에 id="utte-comment"인 태그를 만들고 Vue.js 코드에서는 다음과 같이 처리했다.
mounted() {
console.log("mounted()...");
let script = document.createElement("script");
script.setAttribute("src", "https://utteranc.es/client.js");
script.setAttribute("issue-term", "pathname");
script.setAttribute("repo", "toughhyeok/share-blog-comment");
script.setAttribute("theme", "github-light");
script.setAttribute("crossorigin", "anonymous");
script.async = true;
const element = document.getElementById("utte-comment");
element.appendChild(script);
},
mounted()에서 <script>태그를 <div id="utte-comment"> 태그 아래 추가하는 이유는 created() lifecycle에서 document.getElementById("utte-comment") 코드가 실행되었을 때 해당 id의 element를 가져오지 못하는 문제 때문이었다. (created()에 해당 코드를 작성했을 때 undefined에는 appendChild 메소드가 없다는 error가 발생되었다.)
utterances 적용된 모습

'project > share-blog' 카테고리의 다른 글
| [hotamul] 태그 제거되는 버그 수정 (0) | 2022.09.20 |
|---|---|
| [hotamul] Django 실행 시 sqlite3 버전 이슈 (0) | 2022.09.16 |
| [hotamul] EC2에서 Python3.8 설치 및 버전 변경 (0) | 2022.09.16 |
| [hotamul] v-cloak (0) | 2022.09.08 |
| [hotamul] Django request 횟수 줄이기 (+Vue.js) (0) | 2022.09.07 |
Comments