Skip to content

Commit

Permalink
Some time SEO goodness
Browse files Browse the repository at this point in the history
  • Loading branch information
blopker committed Nov 14, 2024
1 parent 9862fa5 commit 7f91645
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
23 changes: 13 additions & 10 deletions assets/js/components/time.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import { JSXElement, Match, Switch } from "solid-js"
import { type JSXElement, Match, Switch, mergeProps } from "solid-js"

type TimeFormat = "short" | "at"

const defaults = {
time: "",
format: "short",
className: "",
}

function Time(props: {
time?: string
format?: TimeFormat
className?: string
children?: JSXElement
}) {
const _props = mergeProps(defaults, props)
const time = () => {
return new Date(props.time!)
return new Date(_props.time)
}
return (
<time class={props.className} dateTime={props.time}>
<time class={_props.className} dateTime={_props.time}>
<Switch>
<Match when={props.format === "short"}>
<Match when={_props.format === "short"}>
<span>
{time().toLocaleTimeString(undefined, {
hour: "2-digit",
minute: "2-digit",
})}
</span>
</Match>
<Match when={props.format === "at"}>
<Match when={_props.format === "at"}>
{time().toLocaleDateString(undefined, {
month: "short",
day: "numeric",
Expand All @@ -42,9 +49,5 @@ function Time(props: {
}

Time.tagName = "t-time"
Time.propsDefault = {
time: "",
format: "short",
className: "",
}
Time.propsDefault = defaults
export default Time
4 changes: 3 additions & 1 deletion totem/circles/templates/circles/_event_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ <h1 class="h3 pb-3 text-white">{{ event.circle.title }}</h1>
<div class="p-5">
<div class="flex items-center justify-between gap-2">
<p class="font-normal text-gray-700">
<t-time time="{{ event.start|date:'c' }}" format="at"></t-time>
<t-time time="{{ event.start|date:'c' }}" format="at">
{{ event.start|date:"M d, Y gA T" }}</t-time
>
</p>
<a
href="{% url "circles:event_detail" event_slug=event.slug %}"
Expand Down
8 changes: 7 additions & 1 deletion totem/circles/templates/circles/_event_detail_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ <h1 class="h1 pb-3 text-white">{{ object.title }}</h1>
{% endif %}
<div class="text-white">
with
<a href="{{ object.author.get_keeper_url }}"
<a class="font-semibold" href="{{ object.author.get_keeper_url }}"
>{{ object.author.name }}</a
>
</div>
<div class="text-white">
Starting
<t-time time="{{ event.start|date:'c' }}" format="at"
>{{ event.start|date:"M d, Y gA T" }}</t-time
>
</div>
</div>
<div class="max-w-[150px] self-center md:max-w-[200px] md:self-end">
<a href="{{ object.author.get_keeper_url }}">
Expand Down
1 change: 1 addition & 0 deletions totem/circles/templates/circles/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h2 class="font-semibold">← All Spaces</h2>
eventID="{{ event.slug }}"></t-eventcalendar>
</div>
<div class="mt-5 flex-grow pr-4">
<div class="italic">Updated {{ event.date_modified|date:"M d, Y" }}</div>
<div>
{% if not object.published %}
<div class="text-red-500">This Space is not published yet.</div>
Expand Down

0 comments on commit 7f91645

Please sign in to comment.