Skip to content

Commit 8f24ebd

Browse files
committed
feat: add conditional admonition component
1 parent 10da313 commit 8f24ebd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

sources/academy/webscraping/scraping_basics_javascript2/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ unlisted: true
99
---
1010

1111
import DocCardList from '@theme/DocCardList';
12+
import UrlConditional from '@site/src/components/UrlConditional';
1213

1314
**Learn how to use JavaScript to extract information from websites in this practical course, starting from the absolute basics.**
1415

1516
---
1617

18+
<UrlConditional fragment="old-js-course">
19+
:::tip
20+
You're seeing this because your URL includes `#old-js-course`.
21+
:::
22+
</UrlConditional>
23+
1724
In this course we'll use JavaScript to create an application for watching prices. It'll be able to scrape all product pages of an e-commerce website and record prices. Data from several runs of such program would be useful for seeing trends in price changes, detecting discounts, etc.
1825

1926
![E-commerce listing on the left, JSON with data on the right](./images/scraping.webp)

src/components/UrlConditional.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { useLocation } from '@docusaurus/router';
2+
3+
export default function UrlConditional({fragment, children}) {
4+
const location = useLocation();
5+
const shouldShow = location.hash === `#${fragment}`;
6+
return shouldShow ? <>{children}</> : null;
7+
}

0 commit comments

Comments
 (0)