hlavu / my-ssg Goto Github PK
View Code? Open in Web Editor NEWDemo
Home Page: https://hlavu.github.io/my-ssg/dist/index.html
License: MIT License
Demo
Home Page: https://hlavu.github.io/my-ssg/dist/index.html
License: MIT License
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:
readFolder.js
to accept .md
files.readMDFile.js
file to read the content of the .md
files and generate their appropriate HTML body.<h1>
element.<a>
element.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.
In general, the Readme file is pretty clear and I have some suggestions to improve the documentation:
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.
`text`
will be rendered to <code>text</code>
in the generated HTML file. ---
will be converted to a <hr>
tag.You want to include source code in git, but not generated artifacts (e.g., build output like dist/). I would suggest you remove the dist folder (git rm -fr dist
) and then add a .gitignore file to exclude dist later on. See https://www.atlassian.com/git/tutorials/saving-changes/gitignore.
One tool you can use to generate one is:
npx gitignore node
This will create a .gitignore
file, and you can add dist
to it then add/commit it.
These packages are being included but not used: https://github.com/hlavu/my-ssg/blob/main/package.json#L16-L177. They should be removed.
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
You are mixing const
and var
in https://github.com/hlavu/my-ssg/blob/main/bin/modules/generateHTML.js. Probably you have copy/pasted example code from somewhere, which is fine. However, I would standardize on using either var
or const
, but don't mix them. Using var
means you are working with function scoped variables, and const
means block scoped.
According to our recent discussion, I can update all var
variables inside your code into let
or const
.
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.
The problem possibly starts when the program checks for input path status.
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
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.
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.
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
-c
or --config
flags accept a file path to a JSON config file.-c
or --config
option is provided, ignore all other options (i.e., a config file overrides other options on the command line).dist/
as the output
directory if it isn't specified.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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.