This commit is contained in:
zztkm 2022-09-07 15:32:12 +09:00
commit 198b5e84b1
11 changed files with 103 additions and 30 deletions

26
.github/auto-assign.yaml vendored Normal file
View file

@ -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

14
.github/workflows/auto-assign.yaml vendored Normal file
View file

@ -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

View file

@ -3,6 +3,9 @@ name: CI
on:
push:
branches: [main]
paths-ignore:
- "README.md"
- "example/**"
pull_request:
branches: [main]

View file

@ -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
<!DOCTYPE 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
<!DOCTYPE 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.

View file

@ -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')

View file

@ -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'
}
}

View file

@ -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())

View file

@ -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"]

View file

@ -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)

View file

@ -3,10 +3,10 @@
<head>
<meta charset="utf-8">
<title>@title</title>
<base href="@baseUrl">
<!-- <base href="@baseUrl"> -->
<meta name="description" content="@description" />
</head>
<body>
@contents
</body>
</body>

3
example/post/first.md Normal file
View file

@ -0,0 +1,3 @@
# First post
this is example first post