feat: better preview

Fixes #48
This commit is contained in:
Kazhnuz 2023-05-20 14:48:22 +02:00
parent 3fcc5dfedf
commit f92bdca3da
5 changed files with 43 additions and 4 deletions

View file

@ -5,7 +5,12 @@
<article class="article container-article" id="post-<?php the_ID(); ?>"> <article class="article container-article" id="post-<?php the_ID(); ?>">
<?php if ($haveTitle) { ?> <?php if ($haveTitle) { ?>
<h1 class="page-title"><?php the_title(); ?></h1> <h1 class="page-title"><?php the_title(); ?></h1>
<p class="align-right"><span class="btn-small btn-secondary"> <?php echo reading_time(); ?> </span></p>
<?php $category = get_the_category();
$category_parent_id = $category[0]->category_parent;
if ( get_term( $category_parent_id, 'category' )->slug != "3-gallerie" ) {?>
<p class="align-right pr-half"><span class="btn-small btn-secondary"> <?php echo reading_time(); ?> </span></p>
<?php }?>
<?php } else { ?> <?php } else { ?>
<h1 class="sr-only"><?php the_title(); ?></h1> <h1 class="sr-only"><?php the_title(); ?></h1>
<?php } ?> <?php } ?>

View file

@ -29,7 +29,16 @@
?></div> ?></div>
<div><time><span class="btn-small btn-info small-text"><?php the_time('d/m/Y') ?></span></time></div> <div><time><span class="btn-small btn-info small-text"><?php the_time('d/m/Y') ?></span></time></div>
</div> </div>
<div class="comment-text"><?php comments_number('Pas de commentaire', 'Un commentaire', '% commentaires' );?></div> <div class="comment-text">
<?php $category = get_the_category();
$category_parent_id = $category[0]->category_parent;
if ( get_term( $category_parent_id, 'category' )->slug != "3-gallerie" ) {
echo reading_time();
} else {
echo image_number();
}
?>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -20,4 +20,19 @@ function reading_time() {
return $totalreadingtime; return $totalreadingtime;
} }
function image_number() {
$content = get_post_field( 'post_content', $post->ID );
$count = substr_count( $content, '<img' );
if ($count == 1) {
$timer = " image";
} else {
$timer = " images";
}
$imagenumber = $count . $timer;
return $imagenumber;
}
?> ?>

View file

@ -89,7 +89,7 @@ $comment-peek-height:0px;
line-height: $lineheight !important; line-height: $lineheight !important;
text-align:justify; text-align:justify;
background-color:rgba(0,0,0,0.00); background-color:rgba(0,0,0,0.00);
color:dim(getFontColor()); color: transparentize($color-font, 0.3);
position: relative; position: relative;
overflow:hidden; overflow:hidden;
@ -147,6 +147,12 @@ $comment-peek-height:0px;
width:100%; width:100%;
margin:auto; margin:auto;
&:not(.p-img) {
position:absolute;
top:3rem;
padding:0.5rem;
}
& > img { & > img {
max-width:100%; max-width:100%;
height:auto; height:auto;

View file

@ -2794,7 +2794,7 @@ ul.social {
line-height: 1.6rem !important; line-height: 1.6rem !important;
text-align: justify; text-align: justify;
background-color: rgba(0, 0, 0, 0); background-color: rgba(0, 0, 0, 0);
color: rgba(7, 54, 66, 0.4); color: rgba(7, 54, 66, 0.7);
position: relative; position: relative;
overflow: hidden; } overflow: hidden; }
.preview-content .preview-overlay { .preview-content .preview-overlay {
@ -2836,6 +2836,10 @@ ul.social {
.preview-exerpt > p { .preview-exerpt > p {
width: 100%; width: 100%;
margin: auto; } margin: auto; }
.preview-exerpt > p:not(.p-img) {
position: absolute;
top: 3rem;
padding: 0.5rem; }
.preview-exerpt > p > img { .preview-exerpt > p > img {
max-width: 100%; max-width: 100%;
height: auto; height: auto;