properly add the extra metadata to all pages, even tags
This commit is contained in:
		
							parent
							
								
									fee144a3ec
								
							
						
					
					
						commit
						fca3de03e3
					
				| 
						 | 
					@ -197,10 +197,11 @@ checkedSubstitute t v = do
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Add global information to page metadata for rendering (at this point just the url base)
 | 
					-- | Add global information to page metadata for rendering (at this point just the url base)
 | 
				
			||||||
addGlobalMeta :: Y.Value -> Site MT.Value
 | 
					addGlobalMeta :: Y.Value -> Site MT.Value
 | 
				
			||||||
addGlobalMeta (Y.Object m) = do
 | 
					addGlobalMeta meta = do
 | 
				
			||||||
  r <- use urlBase
 | 
					  r <- use urlBase
 | 
				
			||||||
  rt <- rootedLink'
 | 
					  rt <- rootedLink'
 | 
				
			||||||
  rtp <- rootedPageLink'
 | 
					  rtp <- rootedPageLink'
 | 
				
			||||||
 | 
					  Y.Object m <- (`objMerge` meta) <$> use extraMeta
 | 
				
			||||||
  let l = map (\(k, v) -> (K.toText k, Mu.toMustache v)) $ KM.toList m
 | 
					  let l = map (\(k, v) -> (K.toText k, Mu.toMustache v)) $ KM.toList m
 | 
				
			||||||
  pure . Mu.object $ l ++
 | 
					  pure . Mu.object $ l ++
 | 
				
			||||||
    [ ("root", Mu.toMustache $ T.pack r)
 | 
					    [ ("root", Mu.toMustache $ T.pack r)
 | 
				
			||||||
| 
						 | 
					@ -219,10 +220,9 @@ addExtraMeta :: PageInfo -> Y.Value -> Site Y.Value
 | 
				
			||||||
addExtraMeta pi m = do
 | 
					addExtraMeta pi m = do
 | 
				
			||||||
  metaPath <- metadataFile $ pi ^. pagePath
 | 
					  metaPath <- metadataFile $ pi ^. pagePath
 | 
				
			||||||
  metaExists <- io $ doesFileExist metaPath
 | 
					  metaExists <- io $ doesFileExist metaPath
 | 
				
			||||||
  gem <- use extraMeta
 | 
					 | 
				
			||||||
  objMerge gem <$>
 | 
					 | 
				
			||||||
  if metaExists
 | 
					  if metaExists
 | 
				
			||||||
    then do
 | 
					    then do
 | 
				
			||||||
 | 
					      io $ putStrLn ("M <- " ++ metaPath)
 | 
				
			||||||
      em' <- io $ Y.decodeFileEither metaPath
 | 
					      em' <- io $ Y.decodeFileEither metaPath
 | 
				
			||||||
      case em' of
 | 
					      case em' of
 | 
				
			||||||
        Left pe ->
 | 
					        Left pe ->
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue