-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc1aca1
commit 38e7b7d
Showing
37 changed files
with
1,027 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import MarkdownRenderer from "$lib/display/MarkdownRenderer.svelte" | ||
|
||
export default { | ||
component: MarkdownRenderer, | ||
name: "Markdown", | ||
inputs: [ | ||
{ | ||
name: "markdown", | ||
type: "longText", | ||
defaultValue: "This is a **markdown** block", | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script lang="ts"> | ||
let { | ||
src, | ||
name, | ||
}: { | ||
src?: string, | ||
name: string, | ||
} = $props() | ||
</script> | ||
<div class="author"> | ||
{#if src} | ||
<img | ||
class="author_img" | ||
alt="{name} profile picture" | ||
src={src}> | ||
{/if} | ||
<div class="author_name"> | ||
{ name } | ||
</div> | ||
</div> | ||
<style> | ||
.author { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 8px; | ||
align-items: center; | ||
font-size: 14px; | ||
color: var(--foreground); | ||
} | ||
.author_img { | ||
width: 24px; | ||
height: 24px; | ||
border-radius: 100px; | ||
} | ||
.author_name { | ||
font-weight: 600; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<script lang="ts"> | ||
import Calendar from "svelte-material-icons/Calendar.svelte" | ||
import { onMount, onDestroy } from "svelte" | ||
// if the date difference is less than 3 days, we want to show something like: | ||
// "3 hours ago", "2 days ago", "10 minutes ago", etc. | ||
export let date: Date | ||
function get_day_suffix(day: number) { | ||
switch (day % 10) { | ||
case 1: return "st" | ||
case 2: return "nd" | ||
case 3: return "rd" | ||
default: return "th" | ||
} | ||
} | ||
let now = new Date() | ||
let interval: ReturnType<typeof setInterval> | null = null | ||
onMount(() => { | ||
interval = setInterval(() => { | ||
now = new Date() | ||
}, 5000) | ||
}) | ||
onDestroy(() => { | ||
if (interval) clearInterval(interval) | ||
}) | ||
$: diff = now.getTime() - date.getTime() | ||
$: diff_in_seconds = diff / 1000 | ||
$: diff_in_minutes = diff_in_seconds / 60 | ||
$: diff_in_hours = diff_in_minutes / 60 | ||
$: diff_in_days = diff_in_hours / 24 | ||
$: diff_in_months = diff_in_days / 30 | ||
$: use_ago = diff_in_months <= 2 | ||
$: units_ago = diff_in_hours <= 1 ? "minute" : diff_in_days <= 1 ? "hour" : diff_in_months <= 1 ? "day" : "month" | ||
$: units = diff_in_hours <= 1 ? diff_in_minutes : diff_in_days <= 1 ? diff_in_hours : diff_in_months <= 1 ? diff_in_days : diff_in_months | ||
$: ago = `${Math.ceil(units)} ${units_ago}${units > 1 ? "s" : ""} ago` | ||
$: day_with_suffix = date.getDate() + get_day_suffix(date.getDate()) | ||
$: month = date.toLocaleString("en-us", { month: "short" }) | ||
$: year = date.getFullYear() | ||
</script> | ||
<div class="date"> | ||
<Calendar size={18}/> | ||
<span> | ||
{#if use_ago} | ||
<span>{ ago } - </span> | ||
<!-- {:else} --> | ||
{/if} | ||
<span>{ day_with_suffix } { month } { year }</span> | ||
</span> | ||
</div> | ||
<style> | ||
.date { | ||
display: flex; | ||
gap: 8px; | ||
align-items: center; | ||
font-size: 14px; | ||
opacity: 0.5; | ||
font-weight: 600; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script lang="ts"> | ||
import BlocksArray from "$lib/display/markdown-blocks/BlocksArray.svelte" | ||
import { generate_ast } from "$lib/utils/ast" | ||
export let markdown: string = "" | ||
$: ast = generate_ast(markdown) | ||
</script> | ||
|
||
<BlocksArray blocks={ast.children}/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script lang="ts"> | ||
import type { Blockquote } from "mdast" | ||
import BlocksArray from "./BlocksArray.svelte" | ||
export let block: Blockquote | ||
</script> | ||
<blockquote> | ||
<BlocksArray blocks={block.children}/> | ||
</blockquote> | ||
<style> | ||
blockquote { | ||
margin: 0; | ||
border-left: 4px solid rgba(var(--foreground-rgb), 0.15); | ||
background: rgba(var(--foreground-rgb), 0.05); | ||
padding: 12px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script lang="ts"> | ||
import GenericBlock from "./GenericBlock.svelte" | ||
import type { RootContent } from "mdast" | ||
export let blocks: RootContent[] | ||
</script> | ||
|
||
<div class="blocks-array"> | ||
{#each blocks as block} | ||
<GenericBlock {block}/> | ||
{/each} | ||
</div> | ||
|
||
<style> | ||
.blocks-array { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.5rem; | ||
line-height: 1.25; | ||
width: 100%; | ||
align-items: flex-start; | ||
text-align: inherit; | ||
} | ||
</style> |
Oops, something went wrong.