Ensure all notes have front matter
This commit is contained in:
		
							parent
							
								
									1d4f39b502
								
							
						
					
					
						commit
						cfff3b3737
					
				
							
								
								
									
										16
									
								
								_plugins/empty_front_matter_note_injector.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								_plugins/empty_front_matter_note_injector.rb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| # frozen_string_literal: true | ||||
| 
 | ||||
| EMPTY_FRONT_MATTER = <<~JEKYLL | ||||
|   --- | ||||
|   --- | ||||
| 
 | ||||
| JEKYLL | ||||
| 
 | ||||
| # Inject empty front matter in notes that don't have any | ||||
| Jekyll::Hooks.register :site, :after_init do |site| | ||||
|   Dir.glob(site.collections['notes'].relative_directory + '/**/*.md').each do |filename| | ||||
|     raw_note_content = File.read(filename) | ||||
|     raw_note_content.prepend(EMPTY_FRONT_MATTER) unless raw_note_content.start_with?('---') | ||||
|     File.write(filename, raw_note_content) | ||||
|   end | ||||
| end | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Maxime Vaillancourt
						Maxime Vaillancourt