Skip to content

Commit

Permalink
Update to mithril 2.x, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vrimar committed Oct 7, 2020
1 parent 8a48b64 commit 8bac7a3
Show file tree
Hide file tree
Showing 24 changed files with 2,538 additions and 1,892 deletions.
6 changes: 5 additions & 1 deletion docs/src/components/Content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MethodsTable } from './MethodsTable';
import * as Examples from '../../../src/examples';
import { FocusManager, ResponsiveManager } from '@/';
import { ITag, INavigable } from '@documentalist/client';
import { highlightCode } from '../utils/highlightCode';

FocusManager.showFocusOnlyOnTab();
ResponsiveManager.initialize();
Expand All @@ -16,7 +17,10 @@ export function Content(attrs: IDocumentationData) {
class: [
'Docs-content',
`Docs-content-${pageData.reference}`
].join(' ')
].join(' '),
key: attrs.page,
id: attrs.page,
oncreate: () => highlightCode()
};

return m('section', contentAttrs, [
Expand Down
11 changes: 2 additions & 9 deletions docs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'highlight.js/styles/github-gist.css';
import './style.scss';
import './favicon.ico';
import m from 'mithril';
import Main from './components/Main';
import { highlightCode } from './utils/highlightCode';
import { IMarkdownPluginData, ITypescriptPluginData } from '@documentalist/client';
import { normalizeDocs } from './utils/normalizeDocs';

Expand All @@ -21,17 +19,14 @@ export interface IDocumentationData {
export const GITHUB_ROOT = 'https://github.com/vasilrimar/construct-ui';
export const DEFAULT_ROOT = '/introduction/getting-started';

m.route.prefix('#');
m.route.prefix = '#';

const resolveRoute = (wrapper: m.Component) => ({
onmatch(attrs, requestedPath) {
attrs.docs = docs;
attrs.requestedPath = requestedPath;

window.requestAnimationFrame(() => {
window.scrollTo(0, 0);
highlightCode();
});
window.requestAnimationFrame(() => window.scrollTo(0, 0));
},
render({ attrs }) {
return m(wrapper, { ...attrs });
Expand All @@ -54,5 +49,3 @@ if (module.hot) {
initRoutes(main);
});
}

requestAnimationFrame(() => highlightCode());
4 changes: 3 additions & 1 deletion docs/src/utils/highlightCode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import highlightjs from 'highlight.js';
import 'highlight.js/styles/github-gist.css';

export function highlightCode() {
const blocks = document.querySelectorAll('pre code');

Array.from(blocks).map(block => {
highlightjs.highlightBlock(block);
highlightjs.highlightBlock(block as HTMLElement);
});
}
6 changes: 5 additions & 1 deletion docs/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ const cssLoader = {
{
loader: 'postcss-loader',
options: {
plugins: () => [require('autoprefixer')]
postcssOptions: {
plugins: [
'autoprefixer'
],
}
}
}
],
Expand Down
Loading

0 comments on commit 8bac7a3

Please sign in to comment.