-
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.
Ajout du style pour afficher les catégories (#1)
- Loading branch information
Showing
2 changed files
with
128 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,65 @@ | ||
<script lang="ts"> | ||
import { formatDate } from '$lib/utils' | ||
export let data; | ||
import { formatDate } from "$lib/utils"; | ||
export let data; | ||
</script> | ||
|
||
<!-- SEO --> | ||
<svelte:head> | ||
<title>{data.meta.title}</title> | ||
<meta property="og:type" content="article" /> | ||
<meta property="og:title" content={data.meta.title} /> | ||
<meta name="description" content={data.meta.description} /> | ||
<title>{data.meta.title}</title> | ||
<meta property="og:type" content="article" /> | ||
<meta property="og:title" content={data.meta.title} /> | ||
<meta name="description" content={data.meta.description} /> | ||
</svelte:head> | ||
|
||
{#if data.meta.coverSrc} | ||
{#if data.meta.coverAlt} | ||
<img src={data.meta.coverSrc} alt={data.meta.coverAlt} loading="lazy" /> | ||
{:else} | ||
<img src={data.meta.coverSrc} alt={data.meta.title} loading="lazy" /> | ||
{/if} | ||
{#if data.meta.coverAlt} | ||
<img src={data.meta.coverSrc} alt={data.meta.coverAlt} loading="lazy" /> | ||
{:else} | ||
<img src={data.meta.coverSrc} alt={data.meta.title} loading="lazy" /> | ||
{/if} | ||
{/if} | ||
|
||
<article> | ||
<!-- Title --> | ||
<div> | ||
<h1>{data.meta.title}</h1> | ||
<p>{data.meta.readingTime.text}</p> | ||
<p>Published at {formatDate(data.meta.date)}</p> | ||
<h1>{data.meta.title}</h1> | ||
<p>{data.meta.readingTime.text}</p> | ||
<p>Published at {formatDate(data.meta.date)}</p> | ||
</div> | ||
|
||
<div class="tags"> | ||
{#each data.meta.categories as category} | ||
<span>{category}</span> | ||
{/each} | ||
</div> | ||
<section class="categories"> | ||
{#each data.meta.categories as category} | ||
<span>{category}</span> | ||
{/each} | ||
</section> | ||
|
||
<!-- Post --> | ||
<div class="prose"> | ||
<svelte:component this={data.content} /> | ||
</div> | ||
<div class="prose"> | ||
<svelte:component this={data.content} /> | ||
</div> | ||
</article> | ||
|
||
<style> | ||
img { | ||
position: sticky; | ||
top: 0; | ||
z-index: 10; | ||
} | ||
article { | ||
background-color: white; | ||
z-index: 20; | ||
} | ||
</style> | ||
img { | ||
position: sticky; | ||
top: 0; | ||
z-index: 10; | ||
} | ||
article { | ||
background-color: white; | ||
z-index: 20; | ||
} | ||
section.categories { | ||
display: flex; | ||
gap: 0.5rem; | ||
& > span { | ||
color: var(--color-theme-1); | ||
font-size: 0.8rem; | ||
font-weight: 500; | ||
text-transform: capitalize; | ||
} | ||
} | ||
</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 |
---|---|---|
@@ -1,84 +1,103 @@ | ||
<script lang="ts"> | ||
import { formatDate } from '$lib/utils'; | ||
import { base } from '$app/paths'; | ||
export let data; | ||
import { formatDate } from "$lib/utils"; | ||
import { base } from "$app/paths"; | ||
export let data; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>Liste des postes</title> | ||
<meta name="description" content="Liste des postes ordonné par date" /> | ||
<title>Liste des postes</title> | ||
<meta name="description" content="Liste des postes ordonné par date" /> | ||
</svelte:head> | ||
|
||
<!-- Posts --> | ||
<section> | ||
<ul> | ||
{#each data.posts as post} | ||
<li class="post"> | ||
<a href="{base}/{post.slug}"> | ||
<section class="title"> | ||
<h2>{post.title}</h2> | ||
<section class="data"> | ||
<span class="time">{post.readingTime.text}</span> | ||
<span class="date">{formatDate(post.date)}</span> | ||
</section> | ||
</section> | ||
<p>{post.description}</p> | ||
</a> | ||
</li> | ||
{/each} | ||
</ul> | ||
<ul> | ||
{#each data.posts as post} | ||
<li class="post"> | ||
<a href="{base}/{post.slug}"> | ||
<section class="title"> | ||
<h2>{post.title}</h2> | ||
<section class="data"> | ||
<span class="time">{post.readingTime.text}</span> | ||
<span class="date">{formatDate(post.date)}</span> | ||
</section> | ||
</section> | ||
<section class="categories"> | ||
{#each post.categories as category} | ||
<span> | ||
{category} | ||
</span> | ||
{/each} | ||
</section> | ||
<p>{post.description}</p> | ||
</a> | ||
</li> | ||
{/each} | ||
</ul> | ||
</section> | ||
|
||
<style> | ||
a { | ||
color: var(--color-text); | ||
text-decoration: none; | ||
a { | ||
color: var(--color-text); | ||
text-decoration: none; | ||
& h2 { | ||
color: var(--color-theme-1); | ||
} | ||
} | ||
& h2 { | ||
color: var(--color-theme-1); | ||
} | ||
} | ||
a:hover h2 { | ||
text-decoration: underline; | ||
} | ||
a:hover h2 { | ||
text-decoration: underline; | ||
} | ||
ul { | ||
padding: 0; | ||
} | ||
ul { | ||
padding: 0; | ||
} | ||
.post { | ||
margin-bottom: 1rem; | ||
list-style: none; | ||
padding: 1rem; | ||
border: 1px solid hsl(0, 0%, 100%); | ||
.post { | ||
margin-bottom: 1rem; | ||
list-style: none; | ||
padding: 1rem; | ||
border: 1px solid hsl(0, 0%, 100%); | ||
&:hover { | ||
border-color: hsl(0, 0%, 90%); | ||
} | ||
& section.categories { | ||
display: flex; | ||
gap: 0.5rem; | ||
& .title { | ||
@media screen and (width >= 768px){ | ||
display: flex; | ||
align-items: baseline; | ||
justify-content: space-between; | ||
} | ||
& > span { | ||
color: var(--color-theme-1); | ||
font-size: 0.8rem; | ||
font-weight: 500; | ||
text-transform: capitalize; | ||
} | ||
} | ||
& .data { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-end; | ||
&:hover { | ||
border-color: hsl(0, 0%, 90%); | ||
} | ||
@media screen and (width < 768px){ | ||
flex-direction: row-reverse; | ||
justify-content: space-between; | ||
} | ||
} | ||
& .title { | ||
@media screen and (width >= 768px) { | ||
display: flex; | ||
align-items: baseline; | ||
justify-content: space-between; | ||
} | ||
& .time { | ||
font-size: 0.8rem; | ||
color: #666; | ||
} | ||
} | ||
} | ||
</style> | ||
& .data { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-end; | ||
@media screen and (width < 768px) { | ||
flex-direction: row-reverse; | ||
justify-content: space-between; | ||
} | ||
} | ||
& .time { | ||
font-size: 0.8rem; | ||
color: #666; | ||
} | ||
} | ||
} | ||
</style> |