상세 페이지 카테고리 추가

This commit is contained in:
ByungyeonKim
2021-10-31 03:08:10 +09:00
parent d1c49c9462
commit 21bdb131c0
2 changed files with 5 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ import store from '../store.js';
const Detail = () => `
<div class="article-title">
<p class="top">${store.state.selectedPage.category}</p>
<h2 class="main-title">${store.state.selectedPage.title}</h2>
<span class="author">by ${store.state.selectedPage.mediaName}</span>
</div>

View File

@@ -18,16 +18,16 @@ router.get('/:url', (req, res) => {
const $ = cheerio.load(html.data);
const data = {
title: $('div.article_header > div > div > h2').text(),
category: $(
'div.article_header > div > div > p.top > strong'
).html(),
mainContents: $('div.article.d_article').html(),
mediaName: $('#btn_media').text(),
};
return data;
})
.then((result) => res.send(result))
.catch((error) => {
console.log(error);
});
.then((result) => res.send(result));
});
module.exports = router;