This commit is contained in:
maropboia 2024-05-03 11:38:37 +06:00
parent 551ebcf5b3
commit ce817ee383

View file

@ -1,9 +1,15 @@
<!-- eslint-disable vue/require-v-for-key --> <!-- eslint-disable vue/require-v-for-key -->
<script setup lang="ts"> <script setup lang="ts">
// Import the 'data' object from './posts.data' and rename it to 'posts'
import { data as posts } from './posts.data' import { data as posts } from './posts.data'
// Define a function to format a given date string into a more readable format
const formatDate = (raw: string): string => { const formatDate = (raw: string): string => {
// Create a new Date object using the raw date string
const date = new Date(raw) const date = new Date(raw)
// Return the formatted date string using the toLocaleDateString method
// with the specified locale and options
return date.toLocaleDateString('en-US', { return date.toLocaleDateString('en-US', {
month: 'short', month: 'short',
day: 'numeric' day: 'numeric'
@ -12,28 +18,47 @@ const formatDate = (raw: string): string => {
</script> </script>
<template> <template>
<!-- Wrap the content in a div element -->
<div> <div>
<!-- Section element containing the title and a description -->
<section> <section>
<!-- Flex container for the title and a class for styling -->
<h1 class="flex items-center gap-2">Posts</h1> <h1 class="flex items-center gap-2">Posts</h1>
<!-- Description of the posts section -->
<p>Everything from Monthly Updates to fmhy updates.</p> <p>Everything from Monthly Updates to fmhy updates.</p>
We also have a <!-- Anchor element for the RSS feed with a link and target attributes -->
<a href="/feed.rss" target="_blank" title="RSS feed"> <a href="/feed.rss" target="_blank" title="RSS feed">
<!-- Carbon-RSS icon element -->
<div class="i-carbon-rss vertical-top" /> <div class="i-carbon-rss vertical-top" />
<!-- Text for the RSS feed link -->
RSS feed. RSS feed.
</a> </a>
</section> </section>
<!-- Template element for iterating over the years and posts -->
<template v-for="year in Object.keys(posts).reverse()" :key="year"> <template v-for="year in Object.keys(posts).reverse()" :key="year">
<!-- Heading element for the year -->
<h2>{{ year }}</h2> <h2>{{ year }}</h2>
<!-- Unordered list element for the posts of the current year -->
<ul> <ul>
<!-- Loop through the posts of the current year -->
<li v-for="post of posts[year]" :key="post.url"> <li v-for="post of posts[year]" :key="post.url">
<!-- Article element for each post -->
<article> <article>
<!-- Anchor element for the post link -->
<a :href="post.url" class="border-none">{{ post.title }}</a> <a :href="post.url" class="border-none">{{ post.title }}</a>
<!-- Dash element separating the title and date -->
- -
<!-- Description list element for the post metadata -->
<dl class="m-0 inline"> <dl class="m-0 inline">
<!-- Term element for the published on text -->
<dt class="sr-only">Published on</dt> <dt class="sr-only">Published on</dt>
<!-- Description element for the formatted post date -->
<dd class="m-0 inline"> <dd class="m-0 inline">
<!-- Time element for the post date with the raw date string as the datetime attribute -->
<time :datetime="post.date" class="font-bold"> <time :datetime="post.date" class="font-bold">
<!-- Formatted post date using the formatDate function -->
{{ formatDate(post.date) }} {{ formatDate(post.date) }}
</time> </time>
</dd> </dd>
@ -45,6 +70,7 @@ const formatDate = (raw: string): string => {
</div> </div>
</template> </template>
<!-- Scoped style block for the component -->
<style scoped> <style scoped>
.VPBadge { .VPBadge {
border: 1px solid transparent; border: 1px solid transparent;