Merge branch 'main' of https://github.com/zztkm/vss
This commit is contained in:
commit
198b5e84b1
11 changed files with 103 additions and 30 deletions
26
.github/auto-assign.yaml
vendored
Normal file
26
.github/auto-assign.yaml
vendored
Normal 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
14
.github/workflows/auto-assign.yaml
vendored
Normal 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
|
3
.github/workflows/ci.yaml
vendored
3
.github/workflows/ci.yaml
vendored
|
@ -3,6 +3,9 @@ name: CI
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths-ignore:
|
||||||
|
- "README.md"
|
||||||
|
- "example/**"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
|
|
20
README.md
20
README.md
|
@ -1,7 +1,7 @@
|
||||||
# vss
|
# vss
|
||||||
|
|
||||||
vss is an easy to use static site generator.
|
vss is an easy to use static site generator. With `layout/index.html`, Markdown
|
||||||
With `layout/index.html`, Markdown content, and a little configuration, you can easily build your website!
|
content, and a little configuration, you can easily build your website!
|
||||||
|
|
||||||
- **Easy** to use
|
- **Easy** to use
|
||||||
- Create site content with **Markdown**
|
- Create site content with **Markdown**
|
||||||
|
@ -14,13 +14,13 @@ With `layout/index.html`, Markdown content, and a little configuration, you can
|
||||||
|
|
||||||
## Caution
|
## Caution
|
||||||
|
|
||||||
vss is still under development and the API is not stable.
|
vss is still under development and the API is not stable. Be aware that
|
||||||
Be aware that destructive changes will be made if you use it!
|
disruptive changes may be made!
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Get the binary
|
### Get the binary
|
||||||
|
|
||||||
Download from [Releases](https://github.com/zztkm/vss/releases)
|
Download from [Releases](https://github.com/zztkm/vss/releases)
|
||||||
|
|
||||||
### Build from source
|
### Build from source
|
||||||
|
@ -53,10 +53,10 @@ Currently, be sure to configure the following
|
||||||
│ └── main.css
|
│ └── main.css
|
||||||
└── js
|
└── js
|
||||||
└── main.js
|
└── main.js
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
❯ cat index.md
|
❯ cat index.md
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
# Open Sea
|
# Open Sea
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ A static site generator
|
||||||
```
|
```
|
||||||
|
|
||||||
❯ cat config.toml
|
❯ cat config.toml
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
title = "Open Sea"
|
title = "Open Sea"
|
||||||
description = "Takumi Tsuruta's home page"
|
description = "Takumi Tsuruta's home page"
|
||||||
|
@ -75,6 +76,7 @@ baseUrl = 'https://zztkm.github.io/vss/'
|
||||||
```
|
```
|
||||||
|
|
||||||
❯ cat layouts/index.html
|
❯ cat layouts/index.html
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
@ -91,11 +93,13 @@ baseUrl = 'https://zztkm.github.io/vss/'
|
||||||
```
|
```
|
||||||
|
|
||||||
Build your site
|
Build your site
|
||||||
|
|
||||||
```
|
```
|
||||||
vss build
|
vss build
|
||||||
```
|
```
|
||||||
|
|
||||||
Output
|
Output
|
||||||
|
|
||||||
```
|
```
|
||||||
❯ tree dist
|
❯ tree dist
|
||||||
dist
|
dist
|
||||||
|
@ -108,6 +112,7 @@ dist
|
||||||
```
|
```
|
||||||
|
|
||||||
❯ cat dist/index.html
|
❯ cat dist/index.html
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
@ -130,4 +135,5 @@ dist
|
||||||
|
|
||||||
## Example
|
## 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.
|
||||||
|
|
|
@ -56,10 +56,22 @@ fn get_config_map() ?map[string]string {
|
||||||
return config_map
|
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)
|
mut file_name := os.file_name(md_path)
|
||||||
file_name = file_name.replace('.md', '')
|
file_name = file_name.replace('.md', '.html')
|
||||||
return file_name + '.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
|
// 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)?
|
template_content := os.read_file(commands.default_template)?
|
||||||
mut config_map := get_config_map()?
|
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')
|
logger.info('start md to html')
|
||||||
for path in md_paths {
|
for path in md_paths {
|
||||||
mut md := os.read_file(path)?
|
mut md := os.read_file(path)?
|
||||||
|
@ -110,9 +122,12 @@ fn build(mut logger log.Log) ? {
|
||||||
contents := markdown.to_html(md)
|
contents := markdown.to_html(md)
|
||||||
config_map['contents'] = contents
|
config_map['contents'] = contents
|
||||||
html := template.parse(template_content, config_map)
|
html := template.parse(template_content, config_map)
|
||||||
filename := get_html_filename(path)
|
html_path := get_html_path(path)
|
||||||
html_path := os.join_path(dist, filename)
|
dist_path := os.join_path(dist, html_path)
|
||||||
os.write_file(html_path, html)?
|
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')
|
logger.info('end md to html')
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,16 @@ module commands
|
||||||
|
|
||||||
import os
|
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() {
|
fn test_get_html_filename() {
|
||||||
test_path := 'index.md'
|
test_path := 'index.md'
|
||||||
html_name := get_html_filename(test_path)
|
mut html_name := get_html_path(test_path)
|
||||||
assert html_name == 'index.html'
|
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'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import cli
|
||||||
pub fn execute() {
|
pub fn execute() {
|
||||||
mut app := cli.Command{
|
mut app := cli.Command{
|
||||||
name: 'vss'
|
name: 'vss'
|
||||||
version: '0.0.7'
|
version: '0.0.9'
|
||||||
description: 'static site generator'
|
description: 'static site generator'
|
||||||
execute: fn (cmd cli.Command) ? {
|
execute: fn (cmd cli.Command) ? {
|
||||||
println(cmd.help_message())
|
println(cmd.help_message())
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
title = "Open Sea"
|
title = "Open Sea"
|
||||||
description = "Takumi Tsuruta's home page"
|
description = "Takumi Tsuruta's home page"
|
||||||
baseUrl = 'https://zztkm.github.io/vss/'
|
# baseUrl = 'https://zztkm.github.io/vss/'
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
ignoreFiles = ["ignore.md", "README.md"]
|
ignoreFiles = ["ignore.md", "README.md"]
|
|
@ -4,4 +4,8 @@ A static site generator
|
||||||
|
|
||||||
- [GitHub](https://github.com/zztkm)
|
- [GitHub](https://github.com/zztkm)
|
||||||
|
|
||||||
[about page](./about.md)
|
## Pages
|
||||||
|
|
||||||
|
- [about page](./about.md)
|
||||||
|
- post
|
||||||
|
- [first](./post/first.md)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>@title</title>
|
<title>@title</title>
|
||||||
<base href="@baseUrl">
|
<!-- <base href="@baseUrl"> -->
|
||||||
<meta name="description" content="@description" />
|
<meta name="description" content="@description" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
3
example/post/first.md
Normal file
3
example/post/first.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# First post
|
||||||
|
|
||||||
|
this is example first post
|
Loading…
Add table
Reference in a new issue