Skip to content

Commit c9f72c4

Browse files
authored
Add dataTable plugin (#2446)
Tables do not support searching and sorting The behaviour can be improved to allow searching and sorting which are common use cases of tables Let’s add the dataTable plugin to enable these features
1 parent cb59668 commit c9f72c4

File tree

137 files changed

+7822
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+7822
-1
lines changed

docs/site.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"mathDelimiters",
2626
"codeBlockWrapButtons",
2727
"web3Form",
28-
"codeBlockCopyButtons"
28+
"codeBlockCopyButtons",
29+
"dataTable"
2930
],
3031
"pluginsContext" : {
3132
"filterTags" : {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
### Plugin: DataTable
2+
3+
The [DataTable](https://datatables.net) plugin enhances the functionality of tables in your MarkBind site by integrating the DataTables library. It allows you to add searching and sorting capabilities to your tables with minimal configuration. The necessary CSS and JavaScript files are already included in the project, so no additional CDN or plugin context configuration is required.
4+
5+
To enable this plugin, simply add `dataTable` to your site's plugins:
6+
7+
```js {heading="site.json"}
8+
{
9+
...
10+
"plugins": [
11+
"dataTable"
12+
]
13+
}
14+
```
15+
16+
To create a table with DataTable features, use one of the following syntaxes:
17+
18+
{{ icon_example }} Sortable Table:
19+
20+
<include src="codeAndOutput.md" boilerplate >
21+
<variable name="highlightStyle">html</variable>
22+
<variable name="code">
23+
<d-table sortable>
24+
| Product | Price | Quantity |
25+
|-----------|-------|----------|
26+
| Apple | $0.50 | 100 |
27+
| Banana | $0.75 | 50 |
28+
| Orange | $0.60 | 75 |
29+
</d-table>
30+
</variable>
31+
</include>
32+
33+
{{ icon_example }} Searchable Table:
34+
35+
<include src="codeAndOutput.md" boilerplate >
36+
<variable name="highlightStyle">html</variable>
37+
<variable name="code">
38+
<d-table searchable>
39+
| Book Title | Author | Year Published |
40+
|---------------------------|------------------|----------------|
41+
| To Kill a Mockingbird | Harper Lee | 1960 |
42+
| 1984 | George Orwell | 1949 |
43+
| Pride and Prejudice | Jane Austen | 1813 |
44+
| The Great Gatsby | F. Scott Fitzgerald | 1925 |
45+
</d-table>
46+
</variable>
47+
</include>
48+
49+
{{ icon_example }} Sortable and Searchable Table:
50+
51+
<include src="codeAndOutput.md" boilerplate >
52+
<variable name="highlightStyle">html</variable>
53+
<variable name="code">
54+
<d-table sortable searchable>
55+
| City | Country | Population |
56+
|-------------|-----------|------------|
57+
| New York | USA | 8,336,817 |
58+
| London | UK | 9,002,488 |
59+
| Paris | France | 2,161,063 |
60+
| Tokyo | Japan | 13,960,236 |
61+
| Sydney | Australia | 5,367,206 |
62+
</d-table>
63+
</variable>
64+
</include>
65+
66+
The DataTable plugin automatically renders the table with the specified features based on the presence of the `sortable` and `searchable` attributes in the `<d-table>` tag. You can use either one or both attributes to control the desired functionality for each table.

docs/userGuide/usingPlugins.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ MarkBind has a set of built-in plugins that can be used immediately without inst
6464
<include src="plugins/disqus.md" />
6565
<include src="plugins/mathDelimiters.md" />
6666
<include src="plugins/web3Form.md" />
67+
<include src="plugins/dataTable.md" />
6768

6869
## Using External Plugins
6970

packages/cli/test/functional/testSites.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const testSites = [
22
'test_site',
33
'test_site_algolia_plugin',
44
'test_site_special_tags',
5+
'test_site_table_plugin',
56
];
67

78
const testConvertSites = [
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<header>
2+
3+
</header>
4+
5+
<div id="flex-body">
6+
<div id="content-wrapper">
7+
{{ content }}
8+
</div>
9+
<scroll-top-button></scroll-top-button>
10+
</div>
11+
12+
<footer>
13+
14+
</footer>

0 commit comments

Comments
 (0)