diff --git a/.github/auto-assign.yaml b/.github/auto-assign.yaml new file mode 100644 index 0000000..e00c26f --- /dev/null +++ b/.github/auto-assign.yaml @@ -0,0 +1,26 @@ +# Set to true to add reviewers to PRs +addReviewers: true + +# Set to 'author' to add PR's author as a assignee +addAssignees: author + +# A list of reviewers to be added to PRs (GitHub user name) +reviewers: + - zztkm + +# A number of reviewers added to the PR +# Set 0 to add all the reviewers (default: 0) +numberOfReviewers: 1 + +# A list of assignees, overrides reviewers if set +assignees: + - zztkm + +# A number of assignees to add to the PRs +# Set to 0 to add all of the assignees. +# Uses numberOfReviewers if unset. +numberOfAssignees: 0 + +# A list of keywords to be skipped the process if PR's title include it +skipKeywords: + - wip \ No newline at end of file diff --git a/.github/workflows/auto-assign.yaml b/.github/workflows/auto-assign.yaml new file mode 100644 index 0000000..c7a9e4b --- /dev/null +++ b/.github/workflows/auto-assign.yaml @@ -0,0 +1,14 @@ +name: Auto Assign +on: + issues: + types: [opened] + pull_request: + types: [opened] +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: bubkoo/auto-assign@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CONFIG_FILE: .github/auto-assign.yaml \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a2825b8..128215b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,6 +3,9 @@ name: CI on: push: branches: [main] + paths-ignore: + - "README.md" + - "example/**" pull_request: branches: [main] diff --git a/README.md b/README.md index 593fc4d..c1ade8c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # vss -vss is an easy to use static site generator. -With `layout/index.html`, Markdown content, and a little configuration, you can easily build your website! +vss is an easy to use static site generator. With `layout/index.html`, Markdown +content, and a little configuration, you can easily build your website! - **Easy** to use - Create site content with **Markdown** @@ -14,13 +14,13 @@ With `layout/index.html`, Markdown content, and a little configuration, you can ## Caution -vss is still under development and the API is not stable. -Be aware that destructive changes will be made if you use it! - +vss is still under development and the API is not stable. Be aware that +disruptive changes may be made! ## Installation ### Get the binary + Download from [Releases](https://github.com/zztkm/vss/releases) ### Build from source @@ -53,10 +53,10 @@ Currently, be sure to configure the following │ └── main.css └── js └── main.js - ``` ❯ cat index.md + ```markdown # Open Sea @@ -67,14 +67,16 @@ A static site generator [about page](./about.md) ``` -❯ cat config.toml +❯ cat config.toml + ```toml title = "Open Sea" description = "Takumi Tsuruta's home page" baseUrl = 'https://zztkm.github.io/vss/' ``` -❯ cat layouts/index.html +❯ cat layouts/index.html + ```html @@ -91,11 +93,13 @@ baseUrl = 'https://zztkm.github.io/vss/' ``` Build your site + ``` vss build ``` Output + ``` ❯ tree dist dist @@ -107,7 +111,8 @@ dist └── main.js ``` -❯ cat dist/index.html +❯ cat dist/index.html + ```html @@ -130,4 +135,5 @@ dist ## Example -Examples can be found at the [example](https://github.com/zztkm/vss/tree/main/example) directory. +Examples can be found at the +[example](https://github.com/zztkm/vss/tree/main/example) directory. diff --git a/commands/build.v b/commands/build.v index 31d17a1..4e19c91 100644 --- a/commands/build.v +++ b/commands/build.v @@ -56,10 +56,22 @@ fn get_config_map() ?map[string]string { return config_map } -fn get_html_filename(md_path string) string { +fn get_html_path(md_path string) string { mut file_name := os.file_name(md_path) - file_name = file_name.replace('.md', '') - return file_name + '.html' + file_name = file_name.replace('.md', '.html') + dir := os.dir(md_path) + if dir == '.' { + return file_name + } + + return os.join_path(dir, file_name) +} + +fn normalise_paths(paths []string) []string { + cwd := os.getwd() + os.path_separator + mut res := paths.map(os.abs_path(it).replace(cwd, '').replace(os.path_separator, '/')) + res.sort() + return res } // pre_proc_md_to_html convert markdown relative links to html relative links @@ -102,7 +114,7 @@ fn build(mut logger log.Log) ? { template_content := os.read_file(commands.default_template)? mut config_map := get_config_map()? - md_paths := os.walk_ext('.', '.md') + md_paths := normalise_paths(os.walk_ext('.', '.md')) logger.info('start md to html') for path in md_paths { mut md := os.read_file(path)? @@ -110,9 +122,12 @@ fn build(mut logger log.Log) ? { contents := markdown.to_html(md) config_map['contents'] = contents html := template.parse(template_content, config_map) - filename := get_html_filename(path) - html_path := os.join_path(dist, filename) - os.write_file(html_path, html)? + html_path := get_html_path(path) + dist_path := os.join_path(dist, html_path) + if !os.exists(os.dir(dist_path)) { + os.mkdir_all(os.dir(dist_path))? + } + os.write_file(dist_path, html)? } logger.info('end md to html') diff --git a/commands/build_test.v b/commands/build_test.v index 8354980..f070b99 100644 --- a/commands/build_test.v +++ b/commands/build_test.v @@ -2,14 +2,16 @@ module commands import os -fn normalise_paths(paths []string) []string { - mut res := paths.map(it.replace(os.path_separator, '/')) - res.sort() - return res -} - fn test_get_html_filename() { test_path := 'index.md' - html_name := get_html_filename(test_path) + mut html_name := get_html_path(test_path) assert html_name == 'index.html' + + test_path_2 := './post/example-post.md' + html_name = get_html_path(test_path_2) + $if windows { + assert html_name == '.\\post\\example-post.html' + } $else { + assert html_name == './post/example-post.html' + } } diff --git a/commands/vss.v b/commands/vss.v index 19fa8c2..93910b4 100644 --- a/commands/vss.v +++ b/commands/vss.v @@ -6,7 +6,7 @@ import cli pub fn execute() { mut app := cli.Command{ name: 'vss' - version: '0.0.7' + version: '0.0.9' description: 'static site generator' execute: fn (cmd cli.Command) ? { println(cmd.help_message()) diff --git a/example/config.toml b/example/config.toml index 5362fee..0048965 100644 --- a/example/config.toml +++ b/example/config.toml @@ -1,6 +1,6 @@ title = "Open Sea" description = "Takumi Tsuruta's home page" -baseUrl = 'https://zztkm.github.io/vss/' +# baseUrl = 'https://zztkm.github.io/vss/' [build] -ignoreFiles = ["ignore.md", "README.md"] +ignoreFiles = ["ignore.md", "README.md"] \ No newline at end of file diff --git a/example/index.md b/example/index.md index 97eb530..aff41c3 100644 --- a/example/index.md +++ b/example/index.md @@ -4,4 +4,8 @@ A static site generator - [GitHub](https://github.com/zztkm) -[about page](./about.md) +## Pages + +- [about page](./about.md) +- post + - [first](./post/first.md) diff --git a/example/layouts/index.html b/example/layouts/index.html index 947ca80..98ebf7c 100644 --- a/example/layouts/index.html +++ b/example/layouts/index.html @@ -3,10 +3,10 @@ @title - + @contents - + \ No newline at end of file diff --git a/example/post/first.md b/example/post/first.md new file mode 100644 index 0000000..9a1722b --- /dev/null +++ b/example/post/first.md @@ -0,0 +1,3 @@ +# First post + +this is example first post