From 7287ef953d84dbdca32917e7aac6b20e4527d536 Mon Sep 17 00:00:00 2001 From: Manish Bhattarai Date: Sun, 7 Jan 2024 21:50:25 -0500 Subject: [PATCH 1/2] 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. --- website/docs/joinus/new-rss/start-code.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/joinus/new-rss/start-code.md b/website/docs/joinus/new-rss/start-code.md index 6f9061d0b3a513..525c3cfeac331f 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); From db461c62ae565c47f5ac5307c77b253667c4cda8 Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 8 Jan 2024 04:10:23 +0000 Subject: [PATCH 2/2] docs: fix cn docs too --- .../current/joinus/new-rss/start-code.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 eec52ca0c60bcf..ff13344269fa9b 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);