added site title and base configuration variables
This commit is contained in:
parent
0d1e2cc9a0
commit
a56555b4b1
|
@ -41,6 +41,12 @@ tldr = "clipboard-list"
|
||||||
todo = "circle-check"
|
todo = "circle-check"
|
||||||
warning = "triangle-alert"
|
warning = "triangle-alert"
|
||||||
|
|
||||||
|
[generate]
|
||||||
|
# The site base URL. If supplied, this will be added to a <base> element in the page metadata.
|
||||||
|
sitebase = ""
|
||||||
|
# The site title. If supplied, this will be included in page metadata and used to formulate the default title.
|
||||||
|
sitetitle = ""
|
||||||
|
|
||||||
[templates]
|
[templates]
|
||||||
# The template directory name under the Obsidian vault. Default is ".dragonglass.tmpl".
|
# The template directory name under the Obsidian vault. Default is ".dragonglass.tmpl".
|
||||||
directory = ".dragonglass.tmpl"
|
directory = ".dragonglass.tmpl"
|
||||||
|
|
|
@ -17,6 +17,12 @@ dragonglass_version
|
||||||
python_version
|
python_version
|
||||||
The version number of Python that's running dragonglass.
|
The version number of Python that's running dragonglass.
|
||||||
|
|
||||||
|
site_base:
|
||||||
|
If defined, contains the site base URL.
|
||||||
|
|
||||||
|
site_title:
|
||||||
|
If defined, contains the site title.
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
A list of all tags the page being rendered has, in sorted order.
|
A list of all tags the page being rendered has, in sorted order.
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,18 @@ class Context:
|
||||||
links_section = self.config.get("links", {})
|
links_section = self.config.get("links", {})
|
||||||
return links_section.get("relative", False)
|
return links_section.get("relative", False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def site_base(self) -> str | None:
|
||||||
|
"""Returns the configured site base URL."""
|
||||||
|
generate_section = self.config.get("generate", {})
|
||||||
|
return generate_section.get("sitebase", None)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def site_title(self) -> str | None:
|
||||||
|
"""Returns the configured site title."""
|
||||||
|
generate_section = self.config.get("generate", {})
|
||||||
|
return generate_section.get("sitetitle", None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url_prefix(self) -> str:
|
def url_prefix(self) -> str:
|
||||||
"""Returns the configured URL prefix for all URLs generated for internal links."""
|
"""Returns the configured URL prefix for all URLs generated for internal links."""
|
||||||
|
|
|
@ -15,7 +15,15 @@ from ._version import __version__
|
||||||
"""The default template used to render Markdown data."""
|
"""The default template used to render Markdown data."""
|
||||||
DEFAULT_TEMPLATE = """<html>
|
DEFAULT_TEMPLATE = """<html>
|
||||||
<head>
|
<head>
|
||||||
|
{% if site_title is defined %}
|
||||||
|
<title>{{ title }} - {{ site_title }}</title>
|
||||||
|
<meta property="og:site_name" content="{{ site_title }}"/>
|
||||||
|
{% else %}
|
||||||
<title>{{ title }}</title>
|
<title>{{ title }}</title>
|
||||||
|
{% endif %}
|
||||||
|
{% if site_base is defined %}
|
||||||
|
<base href="{{ site_base }}"/>
|
||||||
|
{% endif %}
|
||||||
<link rel="stylesheet" href="{{ default_stylesheet }}"/>
|
<link rel="stylesheet" href="{{ default_stylesheet }}"/>
|
||||||
{% if description|length > 0 %}
|
{% if description|length > 0 %}
|
||||||
<meta name="description" content="{{ description }}"/>
|
<meta name="description" content="{{ description }}"/>
|
||||||
|
@ -99,6 +107,14 @@ def template_vars(node: SourceNode, ctxt: Context) -> dict[str, Any]:
|
||||||
tvars["dragonglass_version"] = __version__
|
tvars["dragonglass_version"] = __version__
|
||||||
tvars["python_version"] = f"{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}"
|
tvars["python_version"] = f"{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}"
|
||||||
|
|
||||||
|
# Add values derived from configuration.
|
||||||
|
t = ctxt.site_base
|
||||||
|
if t:
|
||||||
|
tvars["site_base"] = t
|
||||||
|
t = ctxt.site_title
|
||||||
|
if t:
|
||||||
|
tvars["site_title"] = t
|
||||||
|
|
||||||
# Compute backlinks for this node. Don't include nodes that aren't published.
|
# Compute backlinks for this node. Don't include nodes that aren't published.
|
||||||
backlinks = sorted([n for n in node.backlinks if n.publish], key=lambda n: n.page_title)
|
backlinks = sorted([n for n in node.backlinks if n.publish], key=lambda n: n.page_title)
|
||||||
tvars['backlinks'] = [{'title': n.page_title,
|
tvars['backlinks'] = [{'title': n.page_title,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user