@@ -2,11 +2,11 @@ use super::posts::Post;
22use serde:: { Deserialize , Serialize } ;
33use std:: path:: { Path , PathBuf } ;
44
5- static MANIFEST_FILE : & str = "blog.toml " ;
5+ static MANIFEST_FILE : & str = "_index.md " ;
66static POSTS_EXT : & str = "md" ;
77
88#[ derive( Deserialize ) ]
9- #[ serde( rename_all = "kebab-case" , deny_unknown_fields) ]
9+ #[ serde( deny_unknown_fields) ]
1010pub struct Manifest {
1111 /// Title to display in the "top row".
1212 pub ( crate ) title : String ,
@@ -23,9 +23,6 @@ pub struct Manifest {
2323 /// Raw html describing the blog to insert into the index page.
2424 pub ( crate ) index_html : String ,
2525
26- /// If true, posts require a `team` in their metadata.
27- pub ( crate ) requires_team : bool ,
28-
2926 /// What text to use when linking to this blog in the "see also"
3027 /// section from other blogs.
3128 pub ( crate ) link_text : String ,
@@ -46,15 +43,23 @@ pub struct Blog {
4643
4744impl Blog {
4845 fn load ( prefix : PathBuf , dir : & Path ) -> eyre:: Result < Self > {
49- let manifest_content = std:: fs:: read_to_string ( dir. join ( MANIFEST_FILE ) ) ?;
46+ let manifest_content = std:: fs:: read_to_string ( dir. join ( MANIFEST_FILE ) ) ?
47+ . strip_prefix ( "+++\n " )
48+ . unwrap ( )
49+ . strip_suffix ( "+++\n " )
50+ . unwrap ( )
51+ . to_string ( ) ;
5052 let manifest: Manifest = toml:: from_str ( & manifest_content) ?;
5153
5254 let mut posts = Vec :: new ( ) ;
5355 for entry in std:: fs:: read_dir ( dir) ? {
5456 let path = entry?. path ( ) ;
57+ if path. ends_with ( "_index.md" ) {
58+ continue ; // blog manifest is not a post
59+ }
5560 let ext = path. extension ( ) . and_then ( |e| e. to_str ( ) ) ;
5661 if path. metadata ( ) ?. file_type ( ) . is_file ( ) && ext == Some ( POSTS_EXT ) {
57- posts. push ( Post :: open ( & path, & manifest ) ?) ;
62+ posts. push ( Post :: open ( & path) ?) ;
5863 }
5964 }
6065
@@ -115,8 +120,8 @@ impl Blog {
115120 }
116121}
117122
118- /// Recursively load blogs in a directory. A blog is a directory with a `blog.toml`
119- /// file inside it.
123+ /// Recursively load blogs in a directory. A blog is a directory with a
124+ /// `_index.md` file inside it.
120125pub fn load ( base : & Path ) -> eyre:: Result < Vec < Blog > > {
121126 let mut blogs = Vec :: new ( ) ;
122127 load_recursive ( base, base, & mut blogs) ?;
0 commit comments