Giter Site home page Giter Site logo

my-ssg's People

Contributors

hlavu avatar mqnguyen5 avatar tuanthanh2067 avatar

my-ssg's Issues

Add support for Markdown

I suggest adding initial support for Markdown and would like to work on this feature.

I have created a list of the changes to be made to the code so you can have a look:

  • Modify readFolder.js to accept .md files.
  • Add a new readMDFile.js file to read the content of the .md files and generate their appropriate HTML body.
  • Add implementation to parse Markdown headings to their corresponding <h1> element.
  • Add implementation to parse Markdown link to their corresponding <a> element.
  • Update README.md to add documentation for Markdown support.

Reference for Markdown syntax can be found here.

Let me know if there is anything I should be aware of before making these modifications or if there is a specific way that you want me to do them so I can work on it as soon as possible.

Modifications needed for readme file

In general, the Readme file is pretty clear and I have some suggestions to improve the documentation:

  • Add installation details.
    Since I'm also using NodeJs, I can make a guess on how to install it, but others who are not familiar with NodeJs may need more instructions.
  • Use parallel structures in Features section (optional)
    The documentation will look even more professional if the every feature description has the same structure (eg: full sentence and verb phrase etc.).

Provide error message instead of throwing

In https://github.com/hlavu/my-ssg/blob/main/bin/index.js#L48 you are throwing on the error case. This is not really going to help the user, since your program will simply crash. A better idea would be to print a helpful error message, and call process.exit(1) to have your program exist with an appropriate error code.

Another possibility is to rewrite this code so that you never crash (i.e., ignore the error and continue):

// Try to remove the dist dir.  It might not exist, but we'll ignore that, since it's OK in this case.
try {
  fs.rmdirSync(htmlContainer, { recursive: true });
} catch(err) {
  // we can ignore the error, since we are about to create it...
}

fs.mkdirSync(htmlContainer);
console.log(chalk.bold.green('dist folder is created successfully!'));
}

Also NOTE: you are mixing async and sync code paths with your call to rmdirSync. In general prefer using async versions of all fs methods.

Copy new features from Docusaurus

  • Add full mark down support using markdown-it

  • Add Static Assets for images.

  • Create new option -a or --assets allowing users to specify the path to the assets folder

  • Create an assets folder under ./dist

  • Copy content in the specified assets folder to the ./dist/assets folder

  • Modify path in src attribute in readMDFile.js

  • Update README.md

Unable to process file name / folder name with spaces

The CLI is working well when the input is a name without spaces or when it's wrapped in quotation marks. However, the program can't find the file if there are spaces.
issue3

The problem possibly starts when the program checks for input path status.
issue3-2
When we do node index.js -i a long file name.txt, yargs only takes the 1st word as argv.input, that's why we got the ENOENT error so I believe you can start from there

Expand Usage section of README

The Usage section of the README lists examples of how you can call the program, but doesn't really explain what they do. I would break this up and give more detail so the reader will understand what's happening in each case.

`index.html` links are not properly formatted

I noticed the links generated in your index.html file are not properly formatted:

<h5><a href="./Silver%20Blaze.html">Silver Blaze</h5>
<h5><a href="./The%20Adventure%20of%20the%20Six%20Napoleans.html">The Adventure of the Six Napoleans</h5>
<h5><a href="./The%20Adventure%20of%20the%20Speckled%20Band.html">The Adventure of the Speckled Band</h5>
<h5><a href="./The%20Naval%20Treaty.html">The Naval Treaty</h5>
<h5><a href="./The%20Red%20Headed%20League.html">The Red Headed League</h5>

I don't know if that's your intention, but if it's not, I could make some changes to make them look better.

Add new feature: Support --config with config file

Hello, I have an idea that you can add to your project. Basically, users are now able to pass url as parameters but in case they don't want to do it every time, so I'm thinking of adding a config option to your project, so that users just have to create a file and write their configuration to the file.

Some config files for reference

  "input": "./docs"
{
  "input": "./docs",
  "output": "./web"
}

Task

  • The -c or --config flags accept a file path to a JSON config file.
  • If the file is missing, or can't be parsed as JSON, exit with an appropriate error message.
  • If the -c or --config option is provided, ignore all other options (i.e., a config file overrides other options on the command line).
  • The program should ignore any options in the config file it doesn't recognize. For example, if the SSG doesn't support stylesheets, ignore a stylesheet property.
  • If the config file is missing any options, assume the usual defaults. For example, use dist/ as the output directory if it isn't specified.

Add an optional feature for specifying a language

This feature will allow users to specify a language in which they want the created HTML document use.

Command: node index.js -i testing -l/--lang lang-code

The lang-code then will be added to the root <html lang="lang-code"> tag. By default, the lang value will be en-CA.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.