support for rss/calendar

This commit is contained in:
2023-05-20 19:08:43 -07:00
parent 5689c64c4e
commit e5f7af48cb
14 changed files with 782 additions and 90 deletions

View File

@@ -1,5 +1,5 @@
import { Config } from './conf';
import { AuthorConfig, CalendarConfig, Config, RSSConfig } from './conf';
import { render as mustache_render } from 'mustache';
import { promises as fs } from 'fs';
import { resolve as resolve_path } from 'path';
@@ -7,15 +7,20 @@ import { glob } from 'glob';
import { load_from_dir } from './fs';
import { ColorTheme } from '@doc-utils/color-themes';
import { ThemeGroups } from './build-files';
import { ChangeFreq } from './build-files/sitemap';
export interface Context {
env?: Record<string, string>;
page?: FrontMatter;
base_url: string;
page_url: string;
site_title: string;
author: AuthorConfig | AuthorConfig[];
icons: Record<string, string>;
themes: ColorTheme[];
theme_groups: ThemeGroups;
rss_feeds: RSSConfig[];
calendars: CalendarConfig[];
build_time: {
iso: string;
rfc2822: string;
@@ -26,11 +31,33 @@ export interface Context {
}
export interface FrontMatter {
title?: string;
skip?: boolean;
layout?: string;
title?: string;
description?: string;
tags?: string[];
author?: string | string[];
rss?: RSSFrontmatter;
sitemap?: SitemapFrontmatter;
event?: EventFrontmatter;
[key: string]: unknown;
}
interface SitemapFrontmatter {
change_freq?: ChangeFreq;
priority?: number;
}
interface EventFrontmatter {
start_time?: string;
end_time?: string;
time_zone?: `${string}/${string}`;
}
interface RSSFrontmatter {
//
}
export function render_template(template: string, context: Context, layout?: string, partials: Record<string, string> = { }, tags?: [ string, string ]) {
partials['.content'] = template;
return mustache_render(layout || template, context, partials, tags);