Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: change html example to use items variable instead of item #14205

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions website/docs/joinus/new-rss/start-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ Next, we'll use Cheerio selectors to select the relevant HTML elements, parse th
// We use a Cheerio selector to select all 'div' elements with the class name 'js-navigation-container'
// that contain child elements with the class name 'flex-auto'.
// highlight-start
const item = $('div.js-navigation-container .flex-auto')
const items = $('div.js-navigation-container .flex-auto')
// We use the `toArray()` method to retrieve all the DOM elements selected as an array.
.toArray()
// We use the `map()` method to traverse the array and parse the data we need from each element.
Expand Down Expand Up @@ -366,7 +366,7 @@ module.exports = async (ctx) => {
const { data: response } = await got(`${baseUrl}/${user}/${repo}/issues`);
const $ = cheerio.load(response);

const item = $('div.js-navigation-container .flex-auto')
const items = $('div.js-navigation-container .flex-auto')
.toArray()
.map((item) => {
item = $(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ module.exports = async (ctx) => {
// 我们使用 Cheerio 选择器选择所有带类名“js-navigation-container”的“div”元素,
// 其中包含带类名“flex-auto”的子元素。
// highlight-start
const item = $('div.js-navigation-container .flex-auto')
const items = $('div.js-navigation-container .flex-auto')
// 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。
.toArray()
// 使用“map()”方法遍历数组,并从每个元素中解析需要的数据。
Expand Down Expand Up @@ -363,7 +363,7 @@ module.exports = async (ctx) => {
const { data: response } = await got(`${baseUrl}/${user}/${repo}/issues`);
const $ = cheerio.load(response);

const item = $('div.js-navigation-container .flex-auto')
const items = $('div.js-navigation-container .flex-auto')
.toArray()
.map((item) => {
item = $(item);
Expand Down