Skip to content

Commit

Permalink
include @wq/analyst in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Apr 1, 2024
1 parent d00992c commit c586fb7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ jobs:
run: |
curl -L -s https://unpkg.com/wq > docs/js/wq.js
curl -L -s https://unpkg.com/@wq/markdown@latest > docs/js/markdown.js
cp rest_pandas/static/app/*.js* docs/js
sed -i "s/^import\(.*\)https:\/\/unpkg.com\/wq/import\1.\/wq.js/" docs/js/*.js
sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/markdown@next/import\1.\/markdown.js/" docs/js/*.js
sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/analyst/import\1.\/analyst.js/" docs/js/*.js
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
Expand Down
9 changes: 9 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ wq_config:

[**Django REST Pandas on GitHub**](https://github.com/wq/django-rest-pandas)

### Demo

```js
// @wq/analyst
{
"test": 1
}
```

[pandas]: https://pandas.pydata.org/
[Django REST Framework]: https://www.django-rest-framework.org/
[formats]: ./renderers/index.md
Expand Down
5 changes: 4 additions & 1 deletion docs/js/$index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ layout: null
---

import wq, { modules } from 'https://unpkg.com/wq';
import markdown, { renderers } from 'https://unpkg.com/@wq/markdown@next';
import markdown, { components } from 'https://unpkg.com/@wq/markdown@next';
import Demo from './demo.js';

const React = modules['react'];
const { Typography, Link } = modules['@wq/material'];

components.code = Demo;

wq.use(markdown);

const config = {
Expand Down
30 changes: 30 additions & 0 deletions docs/js/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { modules } from "https://unpkg.com/wq";
import { components } from "https://unpkg.com/@wq/markdown";
import { Analyst } from "https://unpkg.com/@wq/analyst";

const Code = components.code;

export default function CodeDetect(props) {
const { children: value } = props;
if (value.includes("// @wq/analyst")) {
const config = parseConfig(value);
if (config) {
return React.createElement(Analyst, { config });
} else {
return React.createElement(Code, {
children: "// Error parsing @wq/analyst config\n\n" + value,
});
}
} else {
return React.createElement(Code, props);
}
}

function parseConfig(value) {
value = value.replace("// @wq/analyst", "").trim();
try {
return JSON.parse(value);
} catch {
return null;
}
}

0 comments on commit c586fb7

Please sign in to comment.