add microdata

This commit is contained in:
Astro 2022-07-11 00:21:51 +02:00
parent 119e221856
commit b618d1dd05
3 changed files with 10 additions and 9 deletions

4
Cargo.lock generated
View File

@ -1762,7 +1762,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "typed-html"
version = "0.2.2"
source = "git+https://github.com/bodil/typed-html?rev=e18d328951b6b9216976d180f3dea2e6600a3982#e18d328951b6b9216976d180f3dea2e6600a3982"
source = "git+https://github.com/astro/typed-html?branch=microdata#44166b9732920a2b59920dc7a779537132fbf9f2"
dependencies = [
"htmlescape",
"language-tags",
@ -1776,7 +1776,7 @@ dependencies = [
[[package]]
name = "typed-html-macros"
version = "0.2.2"
source = "git+https://github.com/bodil/typed-html?rev=e18d328951b6b9216976d180f3dea2e6600a3982#e18d328951b6b9216976d180f3dea2e6600a3982"
source = "git+https://github.com/astro/typed-html?branch=microdata#44166b9732920a2b59920dc7a779537132fbf9f2"
dependencies = [
"ansi_term",
"lalrpop",

View File

@ -9,4 +9,4 @@ members = [
lto = true
[patch.crates-io]
typed-html = { git = "https://github.com/bodil/typed-html", rev = "e18d328951b6b9216976d180f3dea2e6600a3982" }
typed-html = { git = "https://github.com/astro/typed-html", branch = "microdata" }

View File

@ -101,6 +101,7 @@ fn render_index(app_state: &AppState) -> String {
{ day.events.iter().map(|e| html!(
<article class="event"
itemprop="event" itemscope=true itemtype="https://schema.org/Event"
style=( format!("border-left: 1.5rem solid {}", &config.calendars.get(&e.calendar).map(|o| &o.color[..]).unwrap_or("white")) )>
<p class="time">
{ if e.recurrence {
@ -108,25 +109,25 @@ fn render_index(app_state: &AppState) -> String {
} else {
html!(<span class="recurrence">" "</span>)
} }
<span class="dtstart"
title=( format!("{}", e.dtstart.format("%c")) )>
<span class="dtstart" itemprop="startDate"
title=( format!("{}", e.dtstart.format("%Y-%m-%dT%H:%M:%S")) )>
{ text!("{}", &e.dtstart.format("%H:%M")) }
</span>
</p>
{ match &e.url {
None => html!(
<h3>{ text!("{}", &e.summary) }</h3>
<h3 itemprop="name">{ text!("{}", &e.summary) }</h3>
),
Some(url) => html!(
<h3>
<a href=fix_url(url)>
<h3 itemprop="name">
<a href=fix_url(url) itemprop="url">
{ text!("{}", &e.summary) }
</a>
</h3>
),
} }
<p class="location">
<p class="location" itemprop="location">
{ text!("{}", e.location.as_ref().unwrap_or(&"".to_owned())) }
</p>
</article>