diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..fffa63a9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "typedoc"] + path = typedoc + url = https://github.com/TypeStrong/typedoc diff --git a/.prettierrc.json b/.prettierrc.json index 0967ef42..9fcfde7a 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1 +1,3 @@ -{} +{ + "printWidth": 120 +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..fd0ffd8b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, +} diff --git a/convert.ts b/convert.ts new file mode 100644 index 00000000..da908c6e --- /dev/null +++ b/convert.ts @@ -0,0 +1,21 @@ +import {readFileSync, writeFileSync} from 'fs'; +import { compile } from 'handlebars-to-jsx'; +import {sync as globSync} from 'glob'; +import {outdent} from 'outdent'; + +for(const file of globSync('src/**/*.hbs')) { + console.dir(file); + try { + const converted = compile(readFileSync(file, 'utf8')); + writeFileSync(file.replace(/.hbs$/, '.tsx'), outdent ` + import React from 'react'; + export const component = ${ converted } + + `); + } catch(e) { + // if(e.message.includes('block may only')) { + console.log(e.message); + console.log(`${file}:${e.location?.start?.line}:${e.location?.start?.column}`); + // } + } +} diff --git a/package.json b/package.json index cb318329..8c39386d 100644 --- a/package.json +++ b/package.json @@ -47,5 +47,15 @@ "typescript", "documentation", "generator" - ] + ], + "dependencies": { + "@types/react": "^17.0.14", + "@types/react-dom": "^17.0.9", + "glob": "^7.1.7", + "handlebars-to-jsx": "^0.1.4", + "outdent": "^0.8.0", + "react": "^17.0.2", + "react-dom": "^17.0.2", + "ts-node": "^10.1.0" + } } diff --git a/src/default/layouts/default.hbs b/src/default/layouts/default.hbs index 87722a78..34ef5dfa 100644 --- a/src/default/layouts/default.hbs +++ b/src/default/layouts/default.hbs @@ -3,7 +3,7 @@ - {{#ifCond model.name '==' project.name}}{{project.name}}{{else}}{{model.name}} | {{project.name}}{{/ifCond}} + <IfCond cond="model.name '==' project.name">{{project.name}}</IfCond><IfNotCond cond="model.name '==' project.name">{{model.name}} | {{project.name}}</IfNotCond> @@ -12,7 +12,7 @@ -{{> header}} +{{__partials__.header}}
@@ -23,7 +23,7 @@ @@ -31,7 +31,7 @@ @@ -39,12 +39,12 @@
-{{> footer}} +{{__partials__.footer}}
-{{> analytics}} +{{__partials__.analytics}} diff --git a/src/default/layouts/default.tsx b/src/default/layouts/default.tsx new file mode 100644 index 00000000..1439a8aa --- /dev/null +++ b/src/default/layouts/default.tsx @@ -0,0 +1,56 @@ +import { With, relativeURL, wbr, __partials__, IfCond, IfNotCond, Markdown } from "../../lib"; +import React from "react"; +export const defaultLayout = (props) => ( + <> + + + + + + <IfCond cond={props.model.name === props.project.name}>{props.project.name}</IfCond> + <IfNotCond cond={props.model.name === props.project.name}> + {props.model.name} | {props.project.name} + </IfNotCond> + + + + + + + + + {__partials__.header(props)} + +
+
+
{props.contents}
+
+ + + +
+
+
+ + {__partials__.footer(props)} + +
+ + + {__partials__.analytics(props)} + + + +); diff --git a/src/default/partials/analytics.tsx b/src/default/partials/analytics.tsx new file mode 100644 index 00000000..11280029 --- /dev/null +++ b/src/default/partials/analytics.tsx @@ -0,0 +1,15 @@ +import { With, relativeURL, wbr, __partials__ } from "../../lib"; +import React from "react"; +export const analytics = (props) => + !!props.settings.gaID && ( + <> + {" "} + + + ); diff --git a/src/default/partials/breadcrumb.hbs b/src/default/partials/breadcrumb.hbs index ad63bac7..42a6de51 100644 --- a/src/default/partials/breadcrumb.hbs +++ b/src/default/partials/breadcrumb.hbs @@ -1,5 +1,5 @@ {{#if parent}} - {{#with parent}}{{> breadcrumb}}{{/with}} + {{__partials__.breadcrumb}}
  • {{#if url}} {{name}} diff --git a/src/default/partials/breadcrumb.tsx b/src/default/partials/breadcrumb.tsx new file mode 100644 index 00000000..c6911954 --- /dev/null +++ b/src/default/partials/breadcrumb.tsx @@ -0,0 +1,33 @@ +import { With, relativeURL, wbr, __partials__, Compact, IfCond, IfNotCond, Markdown } from "../../lib"; +import React from "react"; +export const breadcrumb = (props) => + props.parent ? ( + <> + {" "} + {With(props, props.parent, (superProps, props) => ( + <>{__partials__.breadcrumb(props)} + ))} +
  • + {!!props.url ? ( + <> + {" "} + {props.name} + + ) : ( + <> + {" "} + {props.name} + + )}{" "} +
  • + + ) : ( + !!props.url && ( + <> + {" "} +
  • + {props.name} +
  • + + ) + ); diff --git a/src/default/partials/comment.hbs b/src/default/partials/comment.hbs index 1fbd2d78..93412200 100644 --- a/src/default/partials/comment.hbs +++ b/src/default/partials/comment.hbs @@ -1,22 +1,22 @@ -{{#with comment}} + {{#if hasVisibleComponent}}
    {{#if shortText}}
    - {{#markdown}}{{{shortText}}}{{/markdown}} + {{{shortText}}}
    {{/if}} {{#if text}} - {{#markdown}}{{{text}}}{{/markdown}} + {{{text}}} {{/if}} {{#if tags}}
    {{#each tags}}
    {{tagName}}
    -
    {{#markdown}}{{{text}}}{{/markdown}}
    +
    {{{text}}}
    {{/each}}
    {{/if}}
    {{/if}} -{{/with}} \ No newline at end of file +
    diff --git a/src/default/partials/comment.tsx b/src/default/partials/comment.tsx new file mode 100644 index 00000000..b31f9074 --- /dev/null +++ b/src/default/partials/comment.tsx @@ -0,0 +1,47 @@ +import { With, relativeURL, wbr, __partials__, Compact, IfCond, IfNotCond, Markdown } from "../../lib"; +import React from "react"; +export const comment = (props) => ( + <> + {With(props, props.comment, (superProps, props) => ( + <> + {!!props.hasVisibleComponent && ( + <> + {" "} +
    + {!!props.shortText && ( + <> + {" "} +
    + {props.shortText} +
    + + )} + {!!props.text && ( + <> + {" "} + {props.text} + + )} + {!!props.tags && ( + <> + {" "} +
    + {props.tags.map((item, i) => ( + <> + {" "} +
    {item.tagName}
    +
    + {item.text} +
    + + ))}{" "} +
    + + )}{" "} +
    + + )} + + ))} + +); diff --git a/src/default/partials/footer.hbs b/src/default/partials/footer.hbs index e5913db4..06cd7743 100644 --- a/src/default/partials/footer.hbs +++ b/src/default/partials/footer.hbs @@ -1,12 +1,12 @@ - +