Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove "magic" strings MDIMPORT / MYROUTES #322

Closed
1 of 5 tasks
thescientist13 opened this issue Apr 11, 2020 · 1 comment · Fixed by #387
Closed
1 of 5 tasks

remove "magic" strings MDIMPORT / MYROUTES #322

thescientist13 opened this issue Apr 11, 2020 · 1 comment · Fixed by #387
Assignees
Labels
breaking CLI documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc) v0.8.0
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Apr 11, 2020

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

Currently a page template needs at least a MDIMPORT "magic" string that gets templated at build time by the Greenwood CLI. It would be ideal if this could be removed entirely.

This carries on work done as part of #125 where we were able to remove METAIMPORT, METADATA, and METAELEMENT.

We also need to try and do the same for MYROUTES

Details

@thescientist13 thescientist13 added the enhancement Improve something existing (e.g. no docs, new APIs, etc) label Apr 11, 2020
@thescientist13 thescientist13 added this to the MVP milestone Apr 11, 2020
@thescientist13 thescientist13 changed the title remove "magic string" MDIMPORT remove "magic string" MDIMPORT / MYROUTES May 1, 2020
@hutchgrant
Copy link
Member

hutchgrant commented May 2, 2020

You could have the scaffold.js read the template file and then write the string at top or after all the imports to satisfy the mdimport problem. You could do something similar with the other meta magic strings.

The current method:

const templateData = await fs.readFile(pageTemplatePath, 'utf8');

let result = templateData.toString().replace(/entry/g, `wc-md-${file.label}`);
result = result.replace(/MDIMPORT;/, `import '${file.mdFile}';`);

If we use my suggested method we have to read line by line of the app/page-templates and we have to do this for every single page. Far less efficient than simply using the current method. We could also use something like sed or an equivalent for nodejs. But yea, cleaner for the developer just wanting to write a template file in their project.

Just like the <entry></entry> element, the MYROUTES element is needed for specific placement of routes the author wants. You can't eliminate those unless you want to eliminate giving them the choice to place routes/md files however they want in their templates. It's a fundamental feature.

I'd be in agreement with calling it <routes></routes> or something a little more conventional.

@thescientist13 thescientist13 changed the title remove "magic string" MDIMPORT / MYROUTES remove "magic" strings MDIMPORT / MYROUTES May 3, 2020
@thescientist13 thescientist13 added the documentation Greenwood specific docs label May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking CLI documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc) v0.8.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants