@@ -46,6 +46,8 @@ import { mappedIndexToLineCol } from "../core/lib/mapped-text.ts";
4646import { normalizeNewlines } from "../core/lib/text.ts" ;
4747import { DirectiveCell } from "../core/lib/break-quarto-md-types.ts" ;
4848import { QuartoJSONSchema } from "../core/yaml.ts" ;
49+ import { refSchema } from "../core/lib/yaml-schema/common.ts" ;
50+ import { Brand } from "../resources/types/schema-types.ts" ;
4951
5052export function projectExcludeDirs ( context : ProjectContext ) : string [ ] {
5153 const outputDir = projectOutputDir ( context ) ;
@@ -484,3 +486,23 @@ const ensureFileInformationCache = (project: ProjectContext, file: string) => {
484486 }
485487 return project . fileInformationCache . get ( file ) ! ;
486488} ;
489+
490+ export async function projectResolveBrand ( project : ProjectContext ) {
491+ if ( project . brandCache ) {
492+ return project . brandCache . brand ;
493+ }
494+ project . brandCache = { } ;
495+ for ( const brandFile of [ "_brand.yml" , "_brand.yaml" ] ) {
496+ const brandPath = join ( project . dir , brandFile ) ;
497+ if ( ! existsSync ( brandPath ) ) {
498+ continue ;
499+ }
500+ const brand = await readAndValidateYamlFromFile (
501+ brandPath ,
502+ refSchema ( "brand" , "Format-independent brand configuration." ) ,
503+ "Brand validation failed for " + brandPath + "." ,
504+ ) as Brand ;
505+ project . brandCache . brand = brand ;
506+ }
507+ return project . brandCache . brand ;
508+ }
0 commit comments