Skip to content

Commit

Permalink
chore(docs): Add 1.0 Announcement Post (#3984)
Browse files Browse the repository at this point in the history
Let's get this out!
  • Loading branch information
fb55 authored Aug 9, 2024
1 parent 944553b commit 4fe3e7b
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 28 deletions.
21 changes: 0 additions & 21 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,6 @@ support for Cheerio and help us maintain and improve this open source project.

<!-- END SPONSORS -->

## Special Thanks

This library stands on the shoulders of some incredible developers. A special
thanks to:

**&#8226; @fb55 for htmlparser2 & css-select:** Felix has a knack for writing
speedy parsing engines. He completely re-wrote both @tautologistic's
`node-htmlparser` and @harry's `node-soupselect` from the ground up, making both
of them much faster and more flexible. Cheerio would not be possible without his
foundational work

**&#8226; @jQuery team for jQuery:** The core API is the best of its class and
despite dealing with all the browser inconsistencies the code base is extremely
clean and easy to follow. Much of cheerio's implementation and documentation is
from jQuery. Thanks guys.

**&#8226; @tj:** The style, the structure, the open-source"-ness" of this
library comes from studying TJ's style and using many of his libraries. This
dude consistently pumps out high-quality libraries and has always been more than
willing to help or answer questions. You rock TJ.

## License

MIT
148 changes: 148 additions & 0 deletions website/blog/2024-08-07-version-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
slug: cheerio-1.0
title: Cheerio 1.0 Released, Batteries Included 🔋
authors: fb55
tags: [release, announcement]
---

# Cheerio 1.0 Released, Batteries Included 🔋

Cheerio 1.0 is out! After 12 release candidates and just a short seven years
after the initial 1.0 release candidate, it is finally time to call Cheerio 1.0
complete. The theme for this release is "batteries included", with common use
cases now supported out of the box.

So grab a pair of double-As, and read below for what's new, what's changed, and
how to upgrade!

<!--truncate-->

## New Website and Documentation

Since the last release, we've published a new website and documentation for
Cheerio. The new site features detailed guides and API documentation to get the
most from Cheerio. Check it out at [cheerio.js.org](https://cheerio.js.org/).

## A new way to load documents

Loading documents into Cheerio has been revamped. Cheerio now supports multiple
loading methods, each tailored to different use cases:

- `load`: The classic method for parsing HTML or XML strings.
- `loadBuffer`: Works with binary data, automatically detecting the document
encoding.
- `stringStream` and `decodeStream`: Parse HTML directly from streams.
- `fromURL`: Fetch and parse HTML from a URL in one go.

Dive deeper into these methods in the
[Loading Documents](http:///docs/basics/loading) tutorial.

## Simplified Data Extraction

The new `extract` method allows you to extract data from an HTML document and
store it in an object. To fetch the latest release of Cheerio from GitHub and
extract the release date and the release notes from the release page is now as
simple as:

```ts
import * as cheerio from 'cheerio';

const $ = await cheerio.fromURL(
'https://github.com/cheeriojs/cheerio/releases',
);
const data = $.extract({
releases: [
{
// First, we select individual release sections.
selector: 'section',
// Then, we extract the release date, name, and notes from each section.
value: {
// Selectors are executed within the context of the selected element.
name: 'h2',
date: {
selector: 'relative-time',
// The actual release date is stored in the `datetime` attribute.
value: 'datetime',
},
notes: {
selector: '.markdown-body',
// We are looking for the HTML content of the element.
value: 'innerHTML',
},
},
},
],
});
```

Read more about all of the available options in the
[Extracting Data](/docs/advanced/extract) guide.

## Breaking Changes and Upgrade Guide

Cheerio 1.0 introduces several breaking changes, most notably:

- The minimum NodeJS version is now 18.17 or higher.
- Import paths were simplified. For example, use `cheerio/slim` instead of
`cheerio/lib/slim`.
- The deprecated default Cheerio instance and static methods were removed.

Before, it was possible to write code like this:

```ts
import cheerio, { html } from 'cheerio';

html(cheerio('<test></test>')); // ~ '<test></test>' -- NO LONGER WORKS
```

Make sure to always load documents first:

```ts
import * as cheerio from 'cheerio';

cheerio.load('<test></test>').html();
```

- htmlparser2 options now reside exclusively under the `xml` key:

```ts
const $ = cheerio.load('<html>', {
xml: {
withStartIndices: true,
},
});
```

- Node types previously re-exported by Cheerio must now be imported directly
from [`domhandler`](https://github.com/fb55/domhandler).

For a comprehensive list of changes, please consult
[the changelog](https://github.com/cheeriojs/cheerio/releases).

## Upgrading to Cheerio 1.0

To upgrade to Cheerio 1.0, just run:

```bash npm2yarn
npm install cheerio@latest
```

## Get Involved

Explore the new features and let us know what you think! Encounter an issue?
Report it on our
[GitHub issue tracker](https://github.com/cheeriojs/cheerio/issues). Have an
idea for an improvement? Pull requests welcome :)

## Thank You

Thanks to [@jugglinmike](https://github.com/jugglinmike) for kick-starting
Cheerio 1.0, and to all the contributors who have helped shape this release. We
couldn't have done it without you.

Thanks to our
[sponsors and backers](https://github.com/cheeriojs/cheerio?sponsor) for
supporting Cheerio's development. If you use Cheerio at work, consider asking
your company to support us!

And finally, thank you for using Cheerio 🙇🙇‍♀️
4 changes: 3 additions & 1 deletion website/blog/authors.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
fb55:
name: Felix Boehm
title: Maintainer of Cheerio
url: https://github.com/fb55
url: https://feedic.com/
image_url: https://github.com/fb55.png
socials:
github: fb55
12 changes: 6 additions & 6 deletions website/docs/advanced/extract.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ description: Extract multiple values at once.

# Extracting Data with the `extract` Method

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

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

0 comments on commit 4fe3e7b

Please sign in to comment.