work on splitting up extras css; start handling build metadata; start building sitemaps
This commit is contained in:
48
src/build-files/mustache.ts
Normal file
48
src/build-files/mustache.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
import { glob } from 'glob';
|
||||
import { read_text } from '../fs';
|
||||
import { BuildState } from './state';
|
||||
import { build_partials, file_hash_matches, map_input_file_to_output_file, map_output_file_to_url, render_page, skip_file, update_metadata } from './helpers';
|
||||
|
||||
export async function render_text_file_templates(state: BuildState) {
|
||||
const promises: Promise<any>[] = [ ];
|
||||
const files = await glob(state.conf.input.text, {
|
||||
absolute: true,
|
||||
cwd: state.conf.input.root,
|
||||
});
|
||||
|
||||
if (! state.partials) {
|
||||
await build_partials(state);
|
||||
}
|
||||
|
||||
for (const in_file of files) {
|
||||
if (state.seen_files.has(in_file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
state.seen_files.add(in_file);
|
||||
|
||||
promises.push(
|
||||
render_text_file_template(state, in_file)
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
export async function render_text_file_template(state: BuildState, in_file: string) {
|
||||
const out_file = await map_input_file_to_output_file(state, in_file);
|
||||
const out_url = map_output_file_to_url(state, out_file);
|
||||
const { frontmatter, text, hash } = await read_text(in_file);
|
||||
|
||||
if (frontmatter?.skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (file_hash_matches(state, in_file, hash)) {
|
||||
return skip_file(state, in_file, out_file, out_url, frontmatter);
|
||||
}
|
||||
|
||||
await render_page(state, out_file, out_url, text, false, frontmatter);
|
||||
update_metadata(state, in_file, hash);
|
||||
}
|
Reference in New Issue
Block a user