Skip to content

Commit 4fe3e7b

Browse files
authored
chore(docs): Add 1.0 Announcement Post (#3984)
Let's get this out!
1 parent 944553b commit 4fe3e7b

File tree

4 files changed

+157
-28
lines changed

4 files changed

+157
-28
lines changed

Readme.md

-21
Original file line numberDiff line numberDiff line change
@@ -242,27 +242,6 @@ support for Cheerio and help us maintain and improve this open source project.
242242

243243
<!-- END SPONSORS -->
244244

245-
## Special Thanks
246-
247-
This library stands on the shoulders of some incredible developers. A special
248-
thanks to:
249-
250-
**&#8226; @fb55 for htmlparser2 & css-select:** Felix has a knack for writing
251-
speedy parsing engines. He completely re-wrote both @tautologistic's
252-
`node-htmlparser` and @harry's `node-soupselect` from the ground up, making both
253-
of them much faster and more flexible. Cheerio would not be possible without his
254-
foundational work
255-
256-
**&#8226; @jQuery team for jQuery:** The core API is the best of its class and
257-
despite dealing with all the browser inconsistencies the code base is extremely
258-
clean and easy to follow. Much of cheerio's implementation and documentation is
259-
from jQuery. Thanks guys.
260-
261-
**&#8226; @tj:** The style, the structure, the open-source"-ness" of this
262-
library comes from studying TJ's style and using many of his libraries. This
263-
dude consistently pumps out high-quality libraries and has always been more than
264-
willing to help or answer questions. You rock TJ.
265-
266245
## License
267246

268247
MIT

website/blog/2024-08-07-version-1.md

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
slug: cheerio-1.0
3+
title: Cheerio 1.0 Released, Batteries Included 🔋
4+
authors: fb55
5+
tags: [release, announcement]
6+
---
7+
8+
# Cheerio 1.0 Released, Batteries Included 🔋
9+
10+
Cheerio 1.0 is out! After 12 release candidates and just a short seven years
11+
after the initial 1.0 release candidate, it is finally time to call Cheerio 1.0
12+
complete. The theme for this release is "batteries included", with common use
13+
cases now supported out of the box.
14+
15+
So grab a pair of double-As, and read below for what's new, what's changed, and
16+
how to upgrade!
17+
18+
<!--truncate-->
19+
20+
## New Website and Documentation
21+
22+
Since the last release, we've published a new website and documentation for
23+
Cheerio. The new site features detailed guides and API documentation to get the
24+
most from Cheerio. Check it out at [cheerio.js.org](https://cheerio.js.org/).
25+
26+
## A new way to load documents
27+
28+
Loading documents into Cheerio has been revamped. Cheerio now supports multiple
29+
loading methods, each tailored to different use cases:
30+
31+
- `load`: The classic method for parsing HTML or XML strings.
32+
- `loadBuffer`: Works with binary data, automatically detecting the document
33+
encoding.
34+
- `stringStream` and `decodeStream`: Parse HTML directly from streams.
35+
- `fromURL`: Fetch and parse HTML from a URL in one go.
36+
37+
Dive deeper into these methods in the
38+
[Loading Documents](http:///docs/basics/loading) tutorial.
39+
40+
## Simplified Data Extraction
41+
42+
The new `extract` method allows you to extract data from an HTML document and
43+
store it in an object. To fetch the latest release of Cheerio from GitHub and
44+
extract the release date and the release notes from the release page is now as
45+
simple as:
46+
47+
```ts
48+
import * as cheerio from 'cheerio';
49+
50+
const $ = await cheerio.fromURL(
51+
'https://github.com/cheeriojs/cheerio/releases',
52+
);
53+
const data = $.extract({
54+
releases: [
55+
{
56+
// First, we select individual release sections.
57+
selector: 'section',
58+
// Then, we extract the release date, name, and notes from each section.
59+
value: {
60+
// Selectors are executed within the context of the selected element.
61+
name: 'h2',
62+
date: {
63+
selector: 'relative-time',
64+
// The actual release date is stored in the `datetime` attribute.
65+
value: 'datetime',
66+
},
67+
notes: {
68+
selector: '.markdown-body',
69+
// We are looking for the HTML content of the element.
70+
value: 'innerHTML',
71+
},
72+
},
73+
},
74+
],
75+
});
76+
```
77+
78+
Read more about all of the available options in the
79+
[Extracting Data](/docs/advanced/extract) guide.
80+
81+
## Breaking Changes and Upgrade Guide
82+
83+
Cheerio 1.0 introduces several breaking changes, most notably:
84+
85+
- The minimum NodeJS version is now 18.17 or higher.
86+
- Import paths were simplified. For example, use `cheerio/slim` instead of
87+
`cheerio/lib/slim`.
88+
- The deprecated default Cheerio instance and static methods were removed.
89+
90+
Before, it was possible to write code like this:
91+
92+
```ts
93+
import cheerio, { html } from 'cheerio';
94+
95+
html(cheerio('<test></test>')); // ~ '<test></test>' -- NO LONGER WORKS
96+
```
97+
98+
Make sure to always load documents first:
99+
100+
```ts
101+
import * as cheerio from 'cheerio';
102+
103+
cheerio.load('<test></test>').html();
104+
```
105+
106+
- htmlparser2 options now reside exclusively under the `xml` key:
107+
108+
```ts
109+
const $ = cheerio.load('<html>', {
110+
xml: {
111+
withStartIndices: true,
112+
},
113+
});
114+
```
115+
116+
- Node types previously re-exported by Cheerio must now be imported directly
117+
from [`domhandler`](https://github.com/fb55/domhandler).
118+
119+
For a comprehensive list of changes, please consult
120+
[the changelog](https://github.com/cheeriojs/cheerio/releases).
121+
122+
## Upgrading to Cheerio 1.0
123+
124+
To upgrade to Cheerio 1.0, just run:
125+
126+
```bash npm2yarn
127+
npm install cheerio@latest
128+
```
129+
130+
## Get Involved
131+
132+
Explore the new features and let us know what you think! Encounter an issue?
133+
Report it on our
134+
[GitHub issue tracker](https://github.com/cheeriojs/cheerio/issues). Have an
135+
idea for an improvement? Pull requests welcome :)
136+
137+
## Thank You
138+
139+
Thanks to [@jugglinmike](https://github.com/jugglinmike) for kick-starting
140+
Cheerio 1.0, and to all the contributors who have helped shape this release. We
141+
couldn't have done it without you.
142+
143+
Thanks to our
144+
[sponsors and backers](https://github.com/cheeriojs/cheerio?sponsor) for
145+
supporting Cheerio's development. If you use Cheerio at work, consider asking
146+
your company to support us!
147+
148+
And finally, thank you for using Cheerio 🙇🙇‍♀️

website/blog/authors.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
fb55:
22
name: Felix Boehm
33
title: Maintainer of Cheerio
4-
url: https://github.com/fb55
4+
url: https://feedic.com/
55
image_url: https://github.com/fb55.png
6+
socials:
7+
github: fb55

website/docs/advanced/extract.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ description: Extract multiple values at once.
66

77
# Extracting Data with the `extract` Method
88

9-
The `extract` method in Cheerio allows you to extract data from an HTML document
10-
and store it in an object. The method takes a `map` object as a parameter, where
11-
the keys are the names of the properties to be created on the object, and the
12-
values are the selectors or descriptors to be used to extract the values.
9+
The `extract` method allows you to extract data from an HTML document and store
10+
it in an object. The method takes a `map` object as a parameter, where the keys
11+
are the names of the properties to be created on the object, and the values are
12+
the selectors or descriptors to be used to extract the values.
1313

1414
To use the `extract` method, you first need to import the library and load an
1515
HTML document. For example:
@@ -168,11 +168,11 @@ const data = $.extract({
168168
selector: 'section',
169169
// Then, we extract the release date, name, and notes from each section.
170170
value: {
171-
// Selectors are executed whitin the context of the selected element.
171+
// Selectors are executed within the context of the selected element.
172172
name: 'h2',
173173
date: {
174174
selector: 'relative-time',
175-
// The actual date of the release is stored in the `datetime` attribute.
175+
// The actual release date is stored in the `datetime` attribute.
176176
value: 'datetime',
177177
},
178178
notes: {

0 commit comments

Comments
 (0)