Spaces:
Running
Running
File size: 23,379 Bytes
ad5fa41 6b70860 ad5fa41 6b70860 ad5fa41 ab0c87a b9e7b9b a4b9560 b9e7b9b 6105bcd 6b70860 ad5fa41 6b70860 ad5fa41 6b70860 ad5fa41 6b70860 ad5fa41 6b70860 ab0c87a b9e7b9b ad5fa41 b9e7b9b ad5fa41 b9e7b9b ad5fa41 941cf22 c1d1666 f9074bc 941cf22 c1d1666 8d0d788 941cf22 b9e7b9b 8d0d788 597c2dc b9e7b9b ad5fa41 9d8447d b9e7b9b ad5fa41 941cf22 ad5fa41 941cf22 c1d1666 941cf22 b9e7b9b 597c2dc b9e7b9b a4b9560 b9e7b9b a4b9560 b9e7b9b a4b9560 b9e7b9b 6b70860 a4b9560 6b70860 72cfb5a 597c2dc a4b9560 6b70860 72cfb5a 6b70860 a4b9560 597c2dc 72cfb5a a4b9560 72cfb5a a4b9560 b9e7b9b 597c2dc a4b9560 6b70860 b9e7b9b a4b9560 597c2dc b9e7b9b a4b9560 b9e7b9b a4b9560 b9e7b9b 597c2dc b9e7b9b 6b70860 b9e7b9b a4b9560 b9e7b9b 597c2dc b9e7b9b ad5fa41 542395c 2dbf974 542395c a41b32c 542395c 2dbf974 597c2dc 9e27095 6b70860 542395c 2dbf974 597c2dc 9e27095 542395c 9e27095 597c2dc 542395c fa5aa90 c1d1666 fa5aa90 c1d1666 fa5aa90 9d8447d ad5fa41 9d8447d 597c2dc fa5aa90 6b70860 fa5aa90 c1d1666 fa5aa90 c1d1666 fa5aa90 597c2dc fa5aa90 6b70860 a41b32c 6b70860 1ee6ce7 6b70860 a41b32c 6b70860 1ee6ce7 6b70860 fa5aa90 ab0c87a 4e4e67f ab0c87a 4e4e67f ab0c87a 8b344d8 4e4e67f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
import { Image as AstroImage } from 'astro:assets';
import placeholder from '../../assets/image/placeholder.png';
import audioDemo from '../../assets/audio/audio-example.wav';
import HtmlEmbed from '../../../components/HtmlEmbed.astro';
import Sidenote from '../../../components/Sidenote.astro';
import Wide from '../../../components/Wide.astro';
import Note from '../../../components/Note.astro';
import FullWidth from '../../../components/FullWidth.astro';
import Accordion from '../../../components/Accordion.astro';
import Image from '../../../components/Image.astro';
import Quote from '../../../components/Quote.astro';
import Reference from '../../../components/Reference.astro';
import Glossary from '../../../components/Glossary.astro';
import Stack from '../../../components/Stack.astro';
## Components
**All** the following **components** are available in the **article.mdx** file. You can also create your own **components** by creating a new file in the `/components` folder.
### How to import components
To use any component in your MDX file, add the import statement at the top:
```mdx
import Image from '../components/Image.astro';
import Note from '../components/Note.astro';
# Your content
<Image src={myImage} alt="Description" />
<Note>This is a note</Note>
```
Here are the components that are available:
<div className="feature-grid">
<a href="#image" className="feature-card">
<strong>Image</strong>
<span>Optimized images</span>
</a>
<a href="#placement" className="feature-card">
<strong>Placement</strong>
<span>Layout helpers</span>
</a>
<a href="#accordion" className="feature-card">
<strong>Accordion</strong>
<span>Collapsible content</span>
</a>
<a href="#note" className="feature-card">
<strong>Note</strong>
<span>Contextual callouts</span>
</a>
<a href="#quote" className="feature-card">
<strong>Quote</strong>
<span>Elegant citations</span>
</a>
<a href="#htmlembed" className="feature-card">
<strong>HtmlEmbed</strong>
<span>External content</span>
</a>
<a href="#reference" className="feature-card">
<strong>Reference</strong>
<span>Flexible content wrapper</span>
</a>
<a href="#iframe" className="feature-card">
<strong>Iframe</strong>
<span>Web embeds</span>
</a>
<a href="#glossary" className="feature-card">
<strong>Glossary</strong>
<span>Interactive term definitions</span>
</a>
<a href="#stack" className="feature-card">
<strong>Stack</strong>
<span>Flexible grid layouts</span>
</a>
</div>
### Image
**Images** automatically generate optimized `srcset` and `sizes` so the browser downloads the most appropriate file for the current viewport and DPR. You can also request multiple output formats (e.g., **AVIF**, **WebP**, fallback **PNG/JPEG**) and control **lazy loading/decoding** for better **performance**.
<Image
src={placeholder}
zoomable
downloadable
id="placeholder-image"
layout="fixed"
alt="A placeholder image alt text"
caption={'A placeholder image description<br/> Credit: <a target="_blank" href="https://commons.wikimedia.org/wiki/File:RCA_Indian_Head_Test_Pattern.svg">RCA Indian Head Test Pattern</a>'}
/>
| Prop | Required | Description
|------------------------|----------|-------------------------------------------------------
| `zoomable` | No | Adds a zoomable lightbox (Medium-like).
| `downloadable` | No | Adds a download button to fetch the image file.
| `loading="lazy"` | No | Lazy loads the image.
| `caption` | No | Adds a caption and credit.
| `id` | No | Adds an `id` to the outer figure for deep-linking and cross-references.
<Accordion title="Code example">
```mdx
import Image from '../../../components/Image.astro'
import myImage from './assets/image/placeholder.jpg'
<Image src={myImage} alt="Optimized image with caption" />
<Image
src={myImage}
layout="fixed"
zoomable
downloadable
loading="lazy"
alt="Example with caption and credit"
caption={'Optimized image with a descriptive caption. <span class="image-credit">Credit: Photo by <a href="https://example.com">Author</a></span>'}
/>
```
</Accordion>
### Placement
Use these helpers when you need to step outside the main content flow: **Sidenotes** for contextual side notes, **Wide** to extend beyond the main column, and **Full-width** for full-width, immersive sections.
#### Sidenotes
This paragraph presents a **key idea** concisely.
<Sidenote>
**Side note** for brief context or a definition.
</Sidenote>
<Accordion title="Code example">
```mdx
import Sidenote from '../../../components/Sidenote.astro'
Main paragraph with the core idea.
<Sidenote>Short side note.</Sidenote>
```
</Accordion>
#### Wide example
<Wide>
<div className="demo-wide">demo wide</div>
</Wide>
<Accordion title="Code example">
```mdx
import Wide from '../../../components/Wide.astro'
<Wide>
Your content here...
</Wide>
```
</Accordion>
#### Full-width example
<FullWidth>
<div className="demo-full-width">demo full-width</div>
</FullWidth>
<Accordion title="Code example">
```mdx
import FullWidth from '../../../components/FullWidth.astro'
<FullWidth>
Your content here...
</FullWidth>
```
</Accordion>
### Reference
The **Reference** component provides a flexible wrapper for any content with an ID and HTML caption. It's perfect for creating **numbered references**, **cross-references**, or **any content that needs to be referenced** throughout your article.
<Note emoji="💡" variant="info">
**Note:** The `Image` and `HtmlEmbed` components also support the same `id` and `caption` props for consistent referencing across your article.
</Note>
<Reference id="example-reference" caption="<strong>Figure 1:</strong> Example reference with HTML caption and <em>styling</em>">
you content here...
</Reference>
| Prop | Required | Type | Description |
|----------|----------|--------|--------------------------------|
| `id` | Yes | string | Unique identifier for the reference (used for deep-linking) |
| `caption`| Yes | string | HTML caption displayed below the content (supports HTML tags) |
<Accordion title="Code example">
```mdx
import Reference from '../../../components/Reference.astro'
<Reference id="my-reference" caption="<strong>Reference 1:</strong> This is a <em>flexible</em> content wrapper">
<p>Any content can go here...</p>
<img src={myImage} alt="Description" />
<div>Even complex HTML structures!</div>
</Reference>
<Reference id="another-ref" caption="<strong>Table 1:</strong> Data comparison with <a href='#'>source link</a>">
<table>
<thead>
<tr><th>Column 1</th><th>Column 2</th></tr>
</thead>
<tbody>
<tr><td>Data 1</td><td>Data 2</td></tr>
</tbody>
</table>
</Reference>
```
</Accordion>
**Use cases:**
- **Numbered figures** with custom content
- **Cross-references** that can be linked to from anywhere in the article
- **Flexible content blocks** that need consistent styling and captioning
- **Tables, charts, or any content** that requires an ID and description
### Accordion
Can be used like this `<Accordion>some content</Accordion>`. You can pass any children content.
<Accordion title="What is an accordion?" open>
The accordion component provides a collapsible content area that helps organize information efficiently. It's perfect for creating expandable sections, FAQ entries, or any content that benefits from progressive disclosure. Users can click the title to toggle the visibility of the content inside.
</Accordion>
<Accordion title="A table inside an accordion">
| Prop | Required | Description
|-------------|----------|----------------------------------------------------------------------------------
| `src` | Yes | Path to the embed file in the `embeds` folder.
| `title` | No | Short title displayed above the card.
| `desc` | No | Short description displayed below the card. Supports inline HTML (e.g., links).
| `frameless` | No | Removes the card background and border for seamless embeds.
| `align` | No | Aligns the title/description text. One of `left` (default), `center`, `right`.
| `id` | No | Adds an `id` to the outer figure for deep-linking and cross-references.
</Accordion>
<Accordion title="Code example">
````mdx
import Accordion from '../../../components/Accordion.astro'
<Accordion title="Accordion title" open>
<p>Free content with <strong>markdown</strong> and MDX components.</p>
</Accordion>
<Accordion title="A table inside an accordion">
| Prop | Required | Description
|-------------|----------|----------------------------------------------------------------------------------
| `src` | Yes | Path to the embed file in the `embeds` folder.
| `title` | No | Short title displayed above the card.
| `desc` | No | Short description displayed below the card. Supports inline HTML (e.g., links).
| `frameless` | No | Removes the card background and border for seamless embeds.
| `align` | No | Aligns the title/description text. One of `left` (default), `center`, `right`.
| `id` | No | Adds an `id` to the outer figure for deep-linking and cross-references.
</Accordion>
<Accordion title="Code example">
```ts
function greet(name: string) {
console.log(`Hello, ${name}`);
}
greet("Astro");
```
</Accordion>
````
</Accordion>
### Note
Small contextual callout for tips, caveats, or emphasis.
<Note title="Heads‑up" emoji="💡" variant="info">
Use notes to surface context without breaking reading flow.
</Note>
<Note variant="success">
Operation completed successfully.
</Note>
<Note variant="danger">
Be careful: this action cannot be undone.
</Note>
<Note>
Plain note without header. Useful for short clarifications.
</Note>
| Prop | Required | Type | Description |
|----------|----------|------------------------------|-------------------------------------|
| `title` | No | string | Short title displayed in header |
| `emoji` | No | string | Emoji displayed before the title |
| `class` | No | string | Extra classes for custom styling |
| `variant`| No | 'neutral' | 'info' | 'success' | 'danger' | Visual intent of the note |
<Accordion title="Code example">
```mdx
import Note from '../../../components/Note.astro'
<Note title="Heads‑up" emoji="💡" variant="info">
Use notes to surface context without breaking reading flow.
</Note>
<Note variant="success">
Operation completed successfully.
</Note>
<Note variant="danger">
Be careful: this action cannot be undone.
</Note>
<Note>
Plain note without header. Useful for short clarifications.
</Note>
```
</Accordion>
### Quote
Elegant quotes with optional source attribution.
<Quote source="Geoffrey Hinton, <a href='https://www.nature.com/articles/323533a0'>Learning representations by back-propagating errors</a>">
Backpropagation allows neural networks to discover their own internal representations of data.
</Quote>
| Prop | Required | Type | Description |
|----------|----------|--------|--------------------------------|
| `source` | No | HTML | Quote source/author (supports HTML links) |
<Accordion title="Code example">
```mdx
import Quote from '../../../components/Quote.astro'
<Quote source="Geoffrey Hinton, <a href='https://www.nature.com/articles/323533a0'>Learning representations by back-propagating errors</a>">
Backpropagation allows neural networks to discover their own internal representations of data.
</Quote>
```
</Accordion>
### Glossary
The **Glossary** component creates interactive term definitions with hover tooltips. Perfect for **technical terms**, **acronyms**, and **concepts** that need explanation without breaking the reading flow.
<Glossary term="Machine Learning" definition="A subset of artificial intelligence that enables computers to learn and improve from experience without being explicitly programmed." />
<Glossary term="Neural Network" definition="A computing system inspired by biological neural networks, consisting of interconnected nodes (neurons) that process information." position="bottom" />
<Glossary term="API" definition="Application Programming Interface - a set of protocols and tools for building software applications." position="right" disableOnMobile={true} />
<br/><br/>
| Prop | Required | Type | Description
|-------------------|----------|-----------------------------------------|-------------------------------------------------------
| `term` | Yes | `string` | The word or term to define
| `definition` | Yes | `string` | The definition of the term
| `class` | No | `string` | Optional CSS class to apply to the term
| `style` | No | `string` | Optional inline style to apply to the term
| `position` | No | `'top' \| 'bottom' \| 'left' \| 'right'` | Tooltip position (default: 'top')
| `delay` | No | `number` | Delay before showing tooltip in ms (default: 300)
| `disableOnMobile` | No | `boolean` | Disable tooltip on mobile devices (default: false)
<Accordion title="Code example">
```mdx
import Glossary from '../../../components/Glossary.astro'
<Glossary term="Machine Learning" definition="A subset of artificial intelligence that enables computers to learn and improve from experience." />
<Glossary
term="Deep Learning"
definition="A subset of machine learning that uses neural networks with multiple layers to model and understand complex patterns in data."
position="bottom"
delay={500}
/>
<Glossary
term="API"
definition="Application Programming Interface - a set of protocols and tools for building software applications."
disableOnMobile={true}
/>
```
</Accordion>
**Use cases:**
- **Technical terms** that need explanation
- **Acronyms** and abbreviations
- **Domain-specific concepts** for broader audiences
- **Interactive glossaries** for educational content
### Stack
The **Stack** component provides flexible grid layouts for organizing content. Perfect for **comparisons**, **side-by-side examples**, **multi-column layouts**, and **responsive content organization**.
<Stack layout="auto" gap="large">
<div>
<h4>Auto Layout</h4>
<p>This layout automatically adjusts based on content and available space.</p>
</div>
<div>
<h4>Responsive</h4>
<p>Items will wrap to new lines as needed, with a minimum width of 300px.</p>
</div>
<div>
<h4>Flexible</h4>
<p>Perfect for varying content lengths and dynamic layouts.</p>
</div>
</Stack>
<Stack layout="2-column" gap="medium">
<Image
src={placeholder}
alt="First image in stack"
caption="Image 1: Example of using Image component within Stack"
zoomable
/>
<Image
src={placeholder}
alt="Second image in stack"
caption="Image 2: Side-by-side comparison layout"
zoomable
/>
</Stack>
| Prop | Required | Type | Description
|----------|----------|-----------------------------------------------------------------------|-------------------------------------------------------
| `layout` | No | `"2-column" \| "3-column" \| "4-column" \| "auto"` | Grid layout for the content (default: "2-column")
| `gap` | No | `"small" \| "medium" \| "large" \| string` | Gap between items - predefined size or custom value (e.g., "2rem", "20px")
| `class` | No | `string` | Optional CSS class to apply to the wrapper
| `id` | No | `string` | Optional ID for the stack
<Accordion title="Code example">
```mdx
import Stack from '../../../components/Stack.astro'
<Stack layout="auto" gap="large">
<div>
<h4>Auto Layout</h4>
<p>This layout automatically adjusts based on content and available space.</p>
</div>
<div>
<h4>Responsive</h4>
<p>Items will wrap to new lines as needed, with a minimum width of 300px.</p>
</div>
<div>
<h4>Flexible</h4>
<p>Perfect for varying content lengths and dynamic layouts.</p>
</div>
</Stack>
<Stack layout="2-column" gap="medium">
<Image
src={placeholder}
alt="First image in stack"
caption="Image 1: Example of using Image component within Stack"
zoomable
/>
<Image
src={placeholder}
alt="Second image in stack"
caption="Image 2: Side-by-side comparison layout"
zoomable
/>
</Stack>
```
</Accordion>
### Iframes
You can embed external content in your article using **iframes**. For example, **TrackIO**, **Gradio** or even **Github code embeds** can be used this way.
<small className="muted">Trackio embed example</small>
<div className="card">
<iframe src="https://trackio-documentation.hf.space/?project=fake-training-750735&metrics=train_loss,train_accuracy&sidebar=hidden&lang=en" width="100%" height="630" frameborder="0"></iframe>
</div>
<Accordion title="Code example">
```mdx
<iframe frameborder="0" scrolling="no" style="width:100%; height:292px;" allow="clipboard-write" src="https://emgithub.com/iframe.html?target=https%3A%2F%2Fgithub.com%2Fhuggingface%2Fpicotron%2Fblob%2F1004ae37b87887cde597c9060fb067faa060bafe%2Fsetup.py&style=default&type=code&showBorder=on&showLineNumbers=on"></iframe>
<iframe src="https://trackio-documentation.hf.space/?project=fake-training-750735&metrics=train_loss,train_accuracy&sidebar=hidden&lang=en" width="100%" height="600" frameborder="0"></iframe>
<iframe src="https://gradio-hello-world.hf.space" width="100%" height="380" frameborder="0"></iframe>
```
</Accordion>
### HtmlEmbed
The main purpose of the ```HtmlEmbed``` component is to **embed** a **Plotly** or **D3.js** chart in your article. **Libraries** are already imported in the template.
They exist in the `app/src/content/embeds` folder.
For researchers who want to stay in **Python** while targeting **D3**, the [d3blocks](https://github.com/d3blocks/d3blocks) library lets you create interactive D3 charts with only a few lines of code. In **2025**, **D3** often provides more flexibility and a more web‑native rendering than **Plotly** for custom visualizations.
<HtmlEmbed src="d3-line.html" title="This is a chart title" desc="Figure X: Some chart description<br/>Credit: <a href='https://example.com' target='_blank'>Example</a>" />
| Prop | Required | Description
|-------------|----------|----------------------------------------------------------------------------------
| `src` | Yes | Path to the embed file in the `embeds` folder.
| `title` | No | Short title displayed above the card.
| `desc` | No | Short description displayed below the card. Supports inline HTML (e.g., links).
| `frameless` | No | Removes the card background and border for seamless embeds.
| `align` | No | Aligns the title/description text. One of `left` (default), `center`, `right`.
| `id` | No | Adds an `id` to the outer figure for deep-linking and cross-references.
| `data` | No | Path (string) or array of paths (string[]) to data file(s) consumed by the embed.
| `config` | No | Optional object for embed options (e.g., `{ defaultMetric: 'average_rank' }`).
<Accordion title="Code example">
```mdx
import HtmlEmbed from '../../../components/HtmlEmbed.astro'
<HtmlEmbed src="d3-line.html" title="This is a chart title" desc="Some chart description <br/>Credit: <a href='https://example.com' target='_blank'>Example</a>" />
<HtmlEmbed
src="d3-line.html"
title="Comparison A vs B"
data={[ 'formatting_filters.csv', 'relevance_filters.csv' ]}
config={{ defaultMetric: 'average_rank' }}
/>
```
</Accordion>
#### Data
If you need to link your **HTML embeds** to **data files**, there is an **`assets/data`** folder for this.
As long as your files are there, they will be served from the **`public/data`** folder.
You can fetch them with this address: **`[domain]/data/your-data.ext`**
<Note emoji="⚠️" variant="danger"><b>Be careful</b>, unlike images, <b>data files are not optimized</b> by Astro. You need to optimize them manually.</Note>
|