-
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.
Merge pull request #52 from CodeandoMexico/feat/dates
stylized date, reading time, blog
- Loading branch information
Showing
7 changed files
with
52 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script> | ||
export let date = ''; | ||
export let locale; | ||
function processDate(dateString, locale) { | ||
locale ??= 'es-MX' | ||
let formattedDate = new Date(dateString) | ||
let finalDate = formattedDate.toLocaleString(locale, { day: 'numeric', month: 'short', year: 'numeric' }) | ||
return finalDate | ||
} | ||
let finalDate = processDate(date, locale) | ||
</script> | ||
{finalDate} |
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,12 @@ | ||
<script> | ||
export let text = ''; | ||
function readingTime(text) { | ||
const words = text.trim().split(/\s+/).length; | ||
const wpm = 255 //average adult reading speed (words per minute). | ||
const time = Math.ceil(words / wpm); | ||
return time; | ||
} | ||
let minutos = readingTime(text) | ||
</script> | ||
|
||
Tiempo de lectura: {minutos} minutos |
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 |
---|---|---|
@@ -1,19 +1,13 @@ | ||
<script> | ||
export let data | ||
import HumanDate from '@/components/HumanDate.svelte'; | ||
const { aviso } = data | ||
const date_updated = processDate(aviso.date_updated) | ||
function processDate(dateObject, locale) { | ||
locale ??= 'es-mx' | ||
let formattedDate = new Date(dateObject) | ||
let finalDate = formattedDate.toLocaleString(locale, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' }) | ||
return finalDate | ||
} | ||
</script> | ||
|
||
<div id="aviso" class="container mx-auto py-20"> | ||
<div class="w-10/12 p-5 mx-auto w-1/2 mx-auto bg-[url('/grid-bg.png')] bg-slate-200 prose" style={`box-shadow: 7px 7px 1px black;`}> | ||
{@html aviso.content} | ||
<p>Ultima actualización: {date_updated}</p> | ||
<p>Ultima actualización: <HumanDate date={aviso.date_updated}/></p> | ||
</div> | ||
</div> | ||
|
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