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 59c5b25
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ 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
curl -L -s https://unpkg.com/@wq/analyst@latest > docs/js/analyst.js
curl -L -s https://unpkg.com/@wq/chart@next > docs/js/chart.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
sed -i "s/^import\(.*\)https:\/\/unpkg.com\/@wq\/chart/import\1.\/chart.js/" docs/js/*.js
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
Expand Down
9 changes: 9 additions & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
margin-right: auto;
max-width: 100%;
}
.MuiAppBar-colorPrimary img {
border-radius: 4px;
padding-left: 4px;
padding-right: 4px;
margin-left: -18px !important;
margin-top: 4px;
margin-bottom: 4px;
background-color: rgba(0, 0, 0, 0.6);
}
</style>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-LTN8HFGJT2"></script>
<script>
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
7 changes: 6 additions & 1 deletion docs/js/$index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ 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 = {
site_title: 'Django REST Pandas',
logo: '/images/icons/django-rest-pandas.svg',
store: {
service: '',
defaults: {
Expand Down Expand Up @@ -52,6 +56,7 @@ function pageConf(page) {
icon: page.wq_config.icon_data ? page.wq_config.name : null,
markdown: page.content,
list: true,
form: [],
cache: 'all',
can_change: false,
can_add: false,
Expand Down
31 changes: 31 additions & 0 deletions docs/js/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { modules } from "https://unpkg.com/wq";
import { components } from "https://unpkg.com/@wq/markdown";
import { Analyst } from "https://unpkg.com/@wq/analyst";

const React = modules.react;
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 59c5b25

Please sign in to comment.