Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index name change and order exercises #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/hugo-structure.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mappings:
- name: A
exercises:
- B
- C
- B
- name: D
exercises:
- E
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
index := fmt.Sprintf("%02d", i+1)
fullSrc := learningPath + "/" + mapping.Name + "/index.md"
fullTgtDir := targetDir + "/" + index + "-" + mapping.Name
fullTgt := fullTgtDir + "/index.md"
fullTgt := fullTgtDir + "/_index.md"
if !exists(fullTgtDir) {
os.MkdirAll(fullTgtDir, mode)
}
Expand All @@ -84,12 +84,19 @@ func main() {

err = shutil.CopyFile(fullSrc, fullTgt, false)
check(err)
for _, exercise := range mapping.Exercises {
for j, exercise := range mapping.Exercises {
subIndex := fmt.Sprintf("%02d", j+1)
fullSrc := exercisePath + "/" + exercise + "/README.md"
fullTgt := targetDir + "/" + index + "-" + mapping.Name + "/" + exercise + ".md"
fullTgt := targetDir + "/" + index + "-" + mapping.Name + "/" + subIndex + "-" + exercise + ".md"
fmt.Println(fullSrc + " to " + fullTgt)
err = shutil.CopyFile(fullSrc, fullTgt, false)
check(err)
fullSrcImages := exercisePath + "/" + exercise + "/images"
if _, err := os.Stat(fullSrcImages); err == nil {
fullTgtImages := targetDir + "/" + index + "-" + mapping.Name + "/" + subIndex + "-" + exercise + "/images"
err = shutil.CopyTree(fullSrcImages, fullTgtImages, nil)
check(err)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ var _ = Describe("hugo-parser", func() {
result := `mappings:
- name: A
exercises:
- B
- C
- B
- name: D
exercises:
- E`
Expand Down