From 176341e95b7ef784c6183130cbfa80c1249191cf Mon Sep 17 00:00:00 2001 From: Manish Bhattarai Date: Sun, 7 Jan 2024 23:16:11 -0500 Subject: [PATCH] docs: change html example to use items variable instead of item (#14205) * change html example to use items variable instead of item The existing example for HTML retrieval uses 'item' variable on item retrieval, but the final rss output uses the 'items' variable. This results in undefined variable for anyone who directly uses the example code. * docs: fix cn docs too --------- --- website/docs/joinus/new-rss/start-code.md | 4 ++-- .../current/joinus/new-rss/start-code.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/website/docs/joinus/new-rss/start-code.md b/website/docs/joinus/new-rss/start-code.md index 6f9061d0b..525c3cfea 100644 --- a/website/docs/joinus/new-rss/start-code.md +++ b/website/docs/joinus/new-rss/start-code.md @@ -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. @@ -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); diff --git a/website/i18n/zh/docusaurus-plugin-content-docs/current/joinus/new-rss/start-code.md b/website/i18n/zh/docusaurus-plugin-content-docs/current/joinus/new-rss/start-code.md index eec52ca0c..ff1334426 100644 --- a/website/i18n/zh/docusaurus-plugin-content-docs/current/joinus/new-rss/start-code.md +++ b/website/i18n/zh/docusaurus-plugin-content-docs/current/joinus/new-rss/start-code.md @@ -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()”方法遍历数组,并从每个元素中解析需要的数据。 @@ -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);