Skip to content

Commit

Permalink
fix(component name): by default use the filename as the component name
Browse files Browse the repository at this point in the history
  • Loading branch information
thorecaspersen committed Jun 10, 2019
1 parent d4b3044 commit f044558
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
32 changes: 20 additions & 12 deletions lib/flotFyrTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ var through = require("through2");
var replaceExt = require("replace-ext");

module.exports = function(src, dest, markdownOptions) {
// markdownOptions = Object.assign(
// {
// name: "MarkdownReact",
// prependJs: [],
// precompile: false,
// headings: false,
// remarkPlugins: [],
// defualtImport: false,
// importer: false
// },
// markdownOptions
// );
markdownOptions = Object.assign(
{
prependJs: [],
precompile: false,
headings: false,
remarkPlugins: [],
defualtImport: false,
importer: false
},
markdownOptions
);

prettierOption = {
printWidth: 80,
Expand All @@ -41,10 +40,19 @@ module.exports = function(src, dest, markdownOptions) {
if (path.extname(src) !== ".md") {
return null;
}
// get filename without extention ( forxsampel .js)
let filename = path.basename(src, path.extname(src));

return through(function(chunk, enc, done) {
var output = chunk.toString();

// add name to the markdown option if its not set
markdownOptions = Object.assign(
{
name: filename
},
markdownOptions
);
const jsx = toComponentModule(output, markdownOptions);
const beautifulJsx = prettier.format(jsx, prettierOption);

Expand Down
2 changes: 1 addition & 1 deletion lib/toComponentModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const defaultTemplate = require("./templates/default");
module.exports = (input, options) => {
options = Object.assign(
{
name: "MarkdownReact",
name: "defualtNameSetByFlotFyrToComponentModuleFunc",
prependJs: [],
precompile: false,
headings: false,
Expand Down
2 changes: 1 addition & 1 deletion output/testmarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const frontMatter = {
quantity: 834
};

export default class MarkdownReact extends React.PureComponent {
export default class Testmarkdown extends React.PureComponent {
render() {
const props = this.props;
return (
Expand Down

0 comments on commit f044558

Please sign in to comment.