Store the path to the original source file in the blog post object.
This commit is contained in:
		
							parent
							
								
									463be34302
								
							
						
					
					
						commit
						5cac44c625
					
				| @ -163,7 +163,7 @@ async fn load_pages(config: &Config) -> Result<Vec<IPage>, CustomError> { | ||||
|             ret.push( | ||||
|                 IPage::new( | ||||
|                     intermediate_context, | ||||
|                     PageInput::new(relative_to_pages_dir_path, parsed_document), | ||||
|                     PageInput::new(relative_to_pages_dir_path, real_path, parsed_document), | ||||
|                 ) | ||||
|                 .await?, | ||||
|             ); | ||||
|  | ||||
| @ -76,7 +76,11 @@ impl BlogPost { | ||||
|                     ret.push( | ||||
|                         BlogPostPage::new( | ||||
|                             intermediate_context, | ||||
|                             BlogPostPageInput::new(relative_to_post_dir_path, parsed_document), | ||||
|                             BlogPostPageInput::new( | ||||
|                                 relative_to_post_dir_path, | ||||
|                                 real_path, | ||||
|                                 parsed_document, | ||||
|                             ), | ||||
|                         ) | ||||
|                         .await?, | ||||
|                     ); | ||||
|  | ||||
| @ -11,17 +11,23 @@ use super::ISection; | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub(crate) struct BlogPostPageInput<'b, 'parse> { | ||||
|     /// Relative path from the root of the blog post.
 | ||||
|     path: PathBuf, | ||||
| 
 | ||||
|     /// The path to the .org source for the file.
 | ||||
|     src: PathBuf, | ||||
|     document: &'b organic::types::Document<'parse>, | ||||
| } | ||||
| 
 | ||||
| impl<'b, 'parse> BlogPostPageInput<'b, 'parse> { | ||||
|     pub(crate) fn new<P: Into<PathBuf>>( | ||||
|     pub(crate) fn new<P: Into<PathBuf>, S: Into<PathBuf>>( | ||||
|         path: P, | ||||
|         src: S, | ||||
|         document: &'b organic::types::Document<'parse>, | ||||
|     ) -> BlogPostPageInput<'b, 'parse> { | ||||
|         BlogPostPageInput { | ||||
|             path: path.into(), | ||||
|             src: src.into(), | ||||
|             document, | ||||
|         } | ||||
|     } | ||||
| @ -32,6 +38,9 @@ pub(crate) struct BlogPostPage { | ||||
|     /// Relative path from the root of the blog post.
 | ||||
|     pub(crate) path: PathBuf, | ||||
| 
 | ||||
|     /// The path to the .org source for the file.
 | ||||
|     pub(crate) src: PathBuf, | ||||
| 
 | ||||
|     pub(crate) title: Option<String>, | ||||
| 
 | ||||
|     pub(crate) date: Option<String>, | ||||
| @ -79,6 +88,7 @@ intermediate!( | ||||
| 
 | ||||
|         Ok(BlogPostPage { | ||||
|             path: original.path, | ||||
|             src: original.src, | ||||
|             title: get_title(original.document), | ||||
|             date: get_date(original.document), | ||||
|             children, | ||||
|  | ||||
| @ -13,6 +13,9 @@ pub(crate) struct IPage { | ||||
|     /// Relative path from the root of the pages directory.
 | ||||
|     pub(crate) path: PathBuf, | ||||
| 
 | ||||
|     /// The path to the .org source for the file.
 | ||||
|     pub(crate) src: PathBuf, | ||||
| 
 | ||||
|     pub(crate) title: Option<String>, | ||||
| 
 | ||||
|     #[allow(dead_code)] | ||||
| @ -61,6 +64,7 @@ intermediate!( | ||||
| 
 | ||||
|         Ok(IPage { | ||||
|             path: original.path, | ||||
|             src: original.src, | ||||
|             title: get_title(original.document), | ||||
|             date: get_date(original.document), | ||||
|             children, | ||||
| @ -80,17 +84,23 @@ impl IPage { | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub(crate) struct PageInput<'b, 'parse> { | ||||
|     /// Relative path from the root of the page.
 | ||||
|     path: PathBuf, | ||||
| 
 | ||||
|     /// The path to the .org source for the file.
 | ||||
|     src: PathBuf, | ||||
|     document: &'b organic::types::Document<'parse>, | ||||
| } | ||||
| 
 | ||||
| impl<'b, 'parse> PageInput<'b, 'parse> { | ||||
|     pub(crate) fn new<P: Into<PathBuf>>( | ||||
|     pub(crate) fn new<P: Into<PathBuf>, S: Into<PathBuf>>( | ||||
|         path: P, | ||||
|         src: S, | ||||
|         document: &'b organic::types::Document<'parse>, | ||||
|     ) -> PageInput<'b, 'parse> { | ||||
|         PageInput { | ||||
|             path: path.into(), | ||||
|             src: src.into(), | ||||
|             document, | ||||
|         } | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander