make base_url more optional

This commit is contained in:
James Brumond 2023-08-19 15:38:54 -07:00
parent df4545a7f1
commit 5ff9cee8de
Signed by: james
GPG Key ID: E8F2FC44BAA3357A
2 changed files with 5 additions and 6 deletions

View File

@ -24,7 +24,7 @@
"dependencies": {
"@doc-utils/color-themes": "^0.2.0",
"@doc-utils/jsonschema2markdown": "^0.1.1",
"@doc-utils/markdown2html": "^0.3.4",
"@doc-utils/markdown2html": "^0.3.5",
"glob": "^10.2.3",
"ical": "^0.8.0",
"ical-generator": "^4.1.0",

View File

@ -8,9 +8,8 @@ import { render_theme_css_properties } from '../themes';
import { load_partials, FrontMatter, Context, load_layout, render_template, EventFrontmatter } from '../template';
import { render_markdown_to_html, render_markdown_to_html_inline_sync } from '@doc-utils/markdown2html';
import { RSSEntry } from './rss';
import { DateTime } from 'luxon';
import { EventEntry } from './icalendar';
import { as_context_time, as_html_time, from_iso } from '../time';
import { as_context_time, from_iso } from '../time';
import { FileMetadata } from '../metadata';
export interface OutFileURL {
@ -31,9 +30,9 @@ export function map_output_file_to_url(state: BuildState, out_file: string, inde
rel_path = '/' + rel_path;
}
const base_url = state.conf.base_url.endsWith('/')
const base_url = state.conf.base_url?.endsWith('/')
? state.conf.base_url.slice(0, -1)
: state.conf.base_url;
: (state.conf.base_url ?? '');
return {
base_url,
@ -108,7 +107,7 @@ export function mustache_context(state: BuildState, page_url: string, metadata:
return {
env: state.env,
page: frontmatter,
base_url: state.conf.base_url,
base_url: state.conf.base_url ?? '/',
page_url: page_url,
page_published: as_context_time(from_iso(metadata.first_seen_time), 'dt-published'),
page_updated: has_been_updated ? as_context_time(from_iso(metadata.last_updated_time), 'dt-updated') : null,