@@ -51,7 +51,7 @@ impl<'a> Generator<'a> {
51
51
fn new (
52
52
out_directory : impl AsRef < Path > ,
53
53
posts_directory : impl AsRef < Path > ,
54
- ) -> Result < Self , Box < dyn Error > > {
54
+ ) -> eyre :: Result < Self > {
55
55
let mut handlebars = Handlebars :: new ( ) ;
56
56
handlebars. set_strict_mode ( true ) ;
57
57
handlebars. register_templates_directory ( ".hbs" , "templates" ) ?;
@@ -80,7 +80,7 @@ impl<'a> Generator<'a> {
80
80
. replace ( std:: path:: MAIN_SEPARATOR , "/" )
81
81
}
82
82
83
- fn render ( & self ) -> Result < ( ) , Box < dyn Error > > {
83
+ fn render ( & self ) -> eyre :: Result < ( ) > {
84
84
// make sure our output directory exists
85
85
fs:: create_dir_all ( & self . out_directory ) ?;
86
86
@@ -116,7 +116,7 @@ impl<'a> Generator<'a> {
116
116
fs:: write ( "./static/styles/vendor.css" , & concatted) . expect ( "couldn't write vendor css" ) ;
117
117
}
118
118
119
- fn render_blog ( & self , blog : & Blog ) -> Result < ( ) , Box < dyn Error > > {
119
+ fn render_blog ( & self , blog : & Blog ) -> eyre :: Result < ( ) > {
120
120
std:: fs:: create_dir_all ( self . out_directory . join ( blog. prefix ( ) ) ) ?;
121
121
122
122
let path = self . render_index ( blog) ?;
@@ -136,7 +136,7 @@ impl<'a> Generator<'a> {
136
136
Ok ( ( ) )
137
137
}
138
138
139
- fn render_index ( & self , blog : & Blog ) -> Result < PathBuf , Box < dyn Error > > {
139
+ fn render_index ( & self , blog : & Blog ) -> eyre :: Result < PathBuf > {
140
140
let other_blogs: Vec < _ > = self
141
141
. blogs
142
142
. iter ( )
@@ -161,7 +161,7 @@ impl<'a> Generator<'a> {
161
161
Ok ( path)
162
162
}
163
163
164
- fn render_post ( & self , blog : & Blog , post : & Post ) -> Result < PathBuf , Box < dyn Error > > {
164
+ fn render_post ( & self , blog : & Blog , post : & Post ) -> eyre :: Result < PathBuf > {
165
165
let path = blog
166
166
. prefix ( )
167
167
. join ( format ! ( "{:04}" , & post. year) )
@@ -186,7 +186,7 @@ impl<'a> Generator<'a> {
186
186
Ok ( path)
187
187
}
188
188
189
- fn render_feed ( & self , blog : & Blog ) -> Result < ( ) , Box < dyn Error > > {
189
+ fn render_feed ( & self , blog : & Blog ) -> eyre :: Result < ( ) > {
190
190
let posts: Vec < _ > = blog. posts ( ) . iter ( ) . take ( 10 ) . collect ( ) ;
191
191
let data = json ! ( {
192
192
"blog" : blog,
@@ -198,7 +198,7 @@ impl<'a> Generator<'a> {
198
198
Ok ( ( ) )
199
199
}
200
200
201
- fn render_releases_feed ( & self , blog : & Blog ) -> Result < ( ) , Box < dyn Error > > {
201
+ fn render_releases_feed ( & self , blog : & Blog ) -> eyre :: Result < ( ) > {
202
202
let posts = blog. posts ( ) . iter ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
203
203
let is_released: Vec < & Post > = posts. iter ( ) . filter ( |post| post. release ) . collect ( ) ;
204
204
let releases: Vec < ReleasePost > = is_released
@@ -223,7 +223,7 @@ impl<'a> Generator<'a> {
223
223
Ok ( ( ) )
224
224
}
225
225
226
- fn copy_static_files ( & self ) -> Result < ( ) , Box < dyn Error > > {
226
+ fn copy_static_files ( & self ) -> eyre :: Result < ( ) > {
227
227
copy_dir ( "static/fonts" , & self . out_directory ) ?;
228
228
copy_dir ( "static/images" , & self . out_directory ) ?;
229
229
copy_dir ( "static/styles" , & self . out_directory ) ?;
@@ -236,7 +236,7 @@ impl<'a> Generator<'a> {
236
236
name : impl AsRef < Path > ,
237
237
template : & str ,
238
238
data : serde_json:: Value ,
239
- ) -> Result < ( ) , Box < dyn Error > > {
239
+ ) -> eyre :: Result < ( ) > {
240
240
let out_file = self . out_directory . join ( name. as_ref ( ) ) ;
241
241
let file = File :: create ( out_file) ?;
242
242
self . handlebars . render_to_write ( template, & data, file) ?;
@@ -264,7 +264,7 @@ fn copy_dir(source: impl AsRef<Path>, dest: impl AsRef<Path>) -> Result<(), io::
264
264
copy_inner ( source, & dest)
265
265
}
266
266
267
- pub fn main ( ) -> Result < ( ) , Box < dyn Error > > {
267
+ pub fn main ( ) -> eyre :: Result < ( ) > {
268
268
let blog = Generator :: new ( "site" , "posts" ) ?;
269
269
270
270
blog. render ( ) ?;
0 commit comments