mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 19:24:14 +08:00
refactor(tour) extract chapters
This commit is contained in:
46
tour/all.go
46
tour/all.go
@ -1,6 +1,9 @@
|
|||||||
package tour
|
package tour
|
||||||
|
|
||||||
import "sort"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
for _, t := range allTopics {
|
for _, t := range allTopics {
|
||||||
@ -11,20 +14,33 @@ func init() {
|
|||||||
sort.Sort(IDSlice(IDs))
|
sort.Sort(IDSlice(IDs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
Introduction = Chapter(0)
|
||||||
|
FileBasics = Chapter(1)
|
||||||
|
NodeBasics = Chapter(2)
|
||||||
|
MerkleDag = Chapter(3)
|
||||||
|
Network = Chapter(4)
|
||||||
|
Daemon = Chapter(5)
|
||||||
|
Routing = Chapter(6)
|
||||||
|
Exchange = Chapter(7)
|
||||||
|
Ipns = Chapter(8)
|
||||||
|
Mounting = Chapter(9)
|
||||||
|
Plumbing = Chapter(10)
|
||||||
|
Formats = Chapter(11)
|
||||||
|
)
|
||||||
|
|
||||||
// Topics contains a mapping of Tour Topic ID to Topic
|
// Topics contains a mapping of Tour Topic ID to Topic
|
||||||
var allTopics = []Topic{
|
var allTopics = []Topic{
|
||||||
Topic{ID: ID("0.0"), Content: IntroHelloMars},
|
Topic{ID: Introduction(0), Content: IntroHelloMars},
|
||||||
Topic{ID: ID("0.1"), Content: IntroTour},
|
Topic{ID: Introduction(1), Content: IntroTour},
|
||||||
Topic{ID: ID("0.2"), Content: IntroAboutIpfs},
|
Topic{ID: Introduction(2), Content: IntroAboutIpfs},
|
||||||
|
|
||||||
// File Basics
|
Topic{ID: FileBasics(1), Content: FileBasicsFilesystem},
|
||||||
Topic{ID: ID("X.0"), Content: FileBasicsFilesystem},
|
Topic{ID: FileBasics(2), Content: FileBasicsGetting},
|
||||||
Topic{ID: ID("X.1"), Content: FileBasicsGetting},
|
Topic{ID: FileBasics(3), Content: FileBasicsAdding},
|
||||||
Topic{ID: ID("X.2"), Content: FileBasicsAdding},
|
Topic{ID: FileBasics(4), Content: FileBasicsDirectories},
|
||||||
Topic{ID: ID("X.3"), Content: FileBasicsDirectories},
|
Topic{ID: FileBasics(5), Content: FileBasicsDistributed},
|
||||||
Topic{ID: ID("X.3"), Content: FileBasicsDirectories},
|
Topic{ID: FileBasics(6), Content: FileBasicsMounting},
|
||||||
Topic{ID: ID("X.4"), Content: FileBasicsMounting},
|
|
||||||
Topic{ID: ID("X.2"), Content: FileBasicsAdding},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Introduction
|
// Introduction
|
||||||
@ -77,3 +93,9 @@ var FileBasicsMounting = Content{
|
|||||||
Text: `ipfs mount (simple)
|
Text: `ipfs mount (simple)
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Chapter(number int) func(topic int) ID {
|
||||||
|
return func(topic int) ID {
|
||||||
|
return ID(fmt.Sprintf("%d.%d", number, topic))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user