• R/O
  • HTTP
  • SSH
  • HTTPS

hayao.fascode.net: Commit

GitHubのミラーです
https://github.com/Hayao0819/hayao.fascode.net


Commit MetaInfo

Révisione16691e3587524fa23775e851dad3041a5acd6d3 (tree)
l'heure2022-02-02 21:48:25
AuteurHayao0819 <Hayao0819@user...>
CommiterHayao0819

Message de Log

deploy: 4b2771f06cd79de69cfdbd83f96f066cdca10802

Change Summary

Modification

--- a/blog/new-post.v
+++ b/blog/new-post.v
@@ -2,6 +2,7 @@ import os
22 import ui
33 import time
44 import strconv as strc
5+import regex
56 //import eventbus
67
78 const (
@@ -137,6 +138,28 @@ fn create_article(url string, title string){
137138 ui.message_box(result.output)
138139 }
139140
141+ mut re := regex.regex_opt('^title: ".*"$') or {return}
142+ mut path := os.resource_abs_path("./src/content/${filename}")
143+ println(path)
144+ mut article_md := os.read_lines(path) or {
145+ ui.message_box("Failed to open \"$path\"")
146+ return
147+ //exit(1)
148+ }
149+
150+ for cnt,line in article_md{
151+ if re.matches_string(line){
152+ eprintln("書き換え対象を${cnt}行目に発見")
153+ article_md[cnt] = re.replace(line, 'title: "$title"')
154+ eprintln("${line} ==> title: \"$title\"")
155+ break
156+ }
157+ }
158+
159+ os.write_file(path, article_md.join("\n")) or {
160+ ui.message_box("Failed to write to $path")
161+ }
162+
140163 exit(0)
141164 }
142165
Afficher sur ancien navigateur de dépôt.