@@ -3,6 +3,7 @@ package post
33import (
44 "bytes"
55 "fmt"
6+ "os"
67 "path"
78 "regexp"
89 "strconv"
@@ -18,6 +19,7 @@ var CmdPost = &base.Command{
1819 UsageLine : "post" ,
1920 Short : "build post files" ,
2021 Long : "build all post files." ,
22+ Hidden : true ,
2123}
2224
2325func runPost (cmd * base.Command , args []string ) {
@@ -77,7 +79,11 @@ func runPost(cmd *base.Command, args []string) {
7779 buf .WriteString ("\n ---\n " )
7880 buf .WriteString (fmt .Sprintf ("\n ## [答案](https://github.com/openset/leetcode/tree/master/problems/%s)\n " , question .TitleSlug ))
7981 filename := fmt .Sprintf (formatFilename , t .Format ("2006-01-02" ), question .TitleSlug )
80- base .FilePutContents (path .Join ("post" , filename ), buf .Bytes ())
82+ postType := "leetcode"
83+ if inPosts [questionId ] {
84+ postType = "_posts"
85+ }
86+ base .FilePutContents (path .Join (basePath , postType , filename ), buf .Bytes ())
8187 }
8288 }
8389 postTags ()
@@ -91,7 +97,7 @@ func postTags() {
9197 }
9298 filename := fmt .Sprintf ("tag-%s.md" , tag .Slug )
9399 data := []byte (fmt .Sprintf (tagTmpl , title , tag .Slug , tag .Name ))
94- base .FilePutContents (path .Join ("page " , filename ), data )
100+ base .FilePutContents (path .Join (basePath , "_pages " , filename ), data )
95101 }
96102}
97103
@@ -112,3 +118,37 @@ permalink: /tags/%s/
112118taxonomy: %s
113119---
114120`
121+
122+ var homeDir , _ = os .UserHomeDir ()
123+
124+ var basePath = path .Join (homeDir , "openset" , "openset" )
125+
126+ var inPosts = map [int ]bool {
127+ 1 : true ,
128+ 2 : true ,
129+ 3 : true ,
130+ 4 : true ,
131+ 7 : true ,
132+ 8 : true ,
133+ 9 : true ,
134+ 12 : true ,
135+ 13 : true ,
136+ 15 : true ,
137+ 18 : true ,
138+ 20 : true ,
139+ 58 : true ,
140+ 101 : true ,
141+ 168 : true ,
142+ 171 : true ,
143+ 172 : true ,
144+ 190 : true ,
145+ 191 : true ,
146+ 198 : true ,
147+ 233 : true ,
148+ 746 : true ,
149+ 793 : true ,
150+ 849 : true ,
151+ 941 : true ,
152+ 984 : true ,
153+ 1000 : true ,
154+ }
0 commit comments