Skip to content

Commit

Permalink
调整内容页样式
Browse files Browse the repository at this point in the history
Merge pull request #14 from fordes123/dev
  • Loading branch information
fordes123 authored Apr 2, 2024
2 parents c4092ed + 176c5c4 commit a473ce9
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 52 deletions.
2 changes: 1 addition & 1 deletion assets/css/style.min.css

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,22 @@ function printRanked($cids)
echo sprintf(RANKED_ITEM_TEMPLATE, $item->title . ($item->fields->text ? ' - ' . $item->fields->text : ''), $url, $cid, $item->fields->text);
endforeach;
}

function timeago($timestamp)
{
$diff = time() - $timestamp;
$units = array(
'年前' => 31536000,
'个月前' => 2592000,
'天前' => 86400,
'小时前' => 3600,
'分钟前' => 60,
'秒前' => 1,
);
foreach ($units as $unit => $value) {
if ($diff >= $value) {
$time = floor($diff / $value);
return $time . $unit;
}
}
}
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<?php $tool = json_decode($this->options->toolConfig, true);
if (is_array($tool)) :
foreach ($tool as $item) : ?>
<div class='col-4 col-md-2 col-lg-2'>
<div class='col-4 col-md-3 col-md-2 col-lg-2'>
<div class='list-item'>
<div style='background: <?php echo $item['background'] ?>' class='btn btn-link btn-icon btn-md btn-rounded mx-auto mb-2'>
<span><i class='<?php echo $item['icon'] ?>'></i></span>
Expand Down
134 changes: 84 additions & 50 deletions post.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,98 @@

<main class="site-main">
<div class="container">
<div class="post-other-style">
<div class="post-heading text-center pt-3 pt-md-5 pb-3 pb-xl-4">
<h1 class="post-title"> <?php $this->title(); ?></h1>
<div class="post-meta text-muted mt-2 mt-md-3"><?php $this->date(); ?><i class="text-light mx-1"> · </i><span>由 <?php $this->author(); ?> 添加</span></div>
</div>
<div class="card card-xl">
<div class="card-body">
<div class="post-tags"><?php foreach ($this->tags as $tag) { ?><a><?php echo ($tag['name']); ?></a><?php } ?></div>
<div class="post-content">
<div class="post-excerpt"> <i class="excerpt-icon"></i>
<h4><?php echo $this->fields->text ? $this->fields->text : $this->title;?></h4>
</div>
<div>
<?php $this->content(); ?>
</div>
</div>
<div class="post-actions row g-2 mt-4">
<div class="col"> <a href="#" class="btn btn-light btn-icon btn-block btn-lg"><span><i class="far fa-eye"></i></span><b class="num"><?php pageview($this->cid) ?></b></a></div>
<div class="col"> <a href="#" class="btn btn-light btn-icon btn-block btn-lg "><span><i class="far fa-thumbs-up"></i></span></a></div>
<div class="col"> <a href="#" class="btn-share-toggler btn btn-light btn-icon btn-block btn-lg"><span><i class="fas fa-external-link-alt"></i></span></a></div>
<div class="col-12 col-md-7"> <a href="<?php echo $this->fields->url ? $this->fields->url : '#'; ?>" title="<?php $this->title() ?>" target="_blank" class="btn btn-primary btn-lg btn-block btn-goto">访问 <i class="text-lg fas fa-arrow-right"></i></a></div>
</div>
</div>
</div>
<?php if ($this->is('post')) :
$this->related(6)->to($item);
if ($item->have()) : ?>
<div class="post-related card card-xl mt-4 ">
<div class="card-header">
<div class="related-header">
<div class="related-icon"></div>
<div class="h4">猜你喜欢</div>
<div class="container">
<div class="row gx-3 gx-md-4">
<div class="post card card-md mb-3 mb-md-4">
<div class="post-other-style">
<div class="post-heading text-center pt-5 pt-md-5 pb-3 pb-xl-4">
<h1 class="post-title"> <?php $this->title(); ?></h1>
<div class="post-meta d-flex flex-fill justify-content-center align-items-center text-base mt-3 mt-md-3">
<a href="#" class="d-flex align-items-center text-muted">
<div class="flex-avatar w-16 me-2">
<?php echo $this->author->gravatar(16); ?>
</div>
<?php $this->author(); ?>
</a>
<i class="text-light mx-2">•</i>
<span class="date text-muted"><?php echo timeago($this->modified); ?></span>
</div>
</div>
<div class="card-body">
<div class="row g-2 g-md-3 list-grid list-grid-padding">
<?php while ($item->next()) : ?>
<div class="col-12 col-md-6">
<div class="list-item block">
<div href="<?php $item->permalink(); ?>" title="点击查看详情" class="media w-36 rounded-circle">
<img src="<?php $this->options->themeUrl('/assets/image/default.gif'); ?>" data-src="<?php $item->fields->logo(); ?>" class="media-content lazyload" />
</div>
<div href="<?php $item->fields->url(); ?>" cid="<?php $item->cid(); ?>" class="list-content" title="<?php $item->fields->text(); ?>">
<div class="list-body">
<div class="list-title text-md h-1x"><?php $item->title(); ?></div>
<div class="list-desc text-xx text-muted mt-1">
<div class="h-1x"><?php $item->fields->text(); ?></div>
<div class="post-tags">
<?php foreach ($this->tags as $tag) : ?>
<a><?php echo ($tag['name']); ?></a>
<?php endforeach; ?>
</div>
<div class="post-content">
<div class="post-excerpt"> <i class="excerpt-icon"></i>
<h4><?php echo $this->fields->text ? $this->fields->text : $this->title; ?></h4>
</div>
<div class="text-wrap text-break fs-6 mx-3"><?php $this->content(); ?></div>
</div>
<div class="post-actions row g-2 mt-4">
<div class="col">
<a href="#" class="btn btn-light btn-icon btn-block btn-lg disabled">
<span><i class="far fa-eye"></i></span>
<b class="num"><?php pageview($this->cid) ?></b>
</a>
</div>
<div class="col">
<a href="#" class="btn btn-light btn-icon btn-block btn-lg disabled">
<span><i class="far fa-thumbs-up"></i></span>
</a>
</div>
<div class="col">
<a href="#" class="btn-share-toggler btn btn-light btn-icon btn-block btn-lg disabled">
<span><i class="far fa-star"></i></span>
</a>
</div>
<div class="col-12 col-md-7">
<?php if ($this->fields->navigation) : ?>
<a href="<?php $this->fields->url(); ?>" title="<?php $this->title() ?>" target="_blank" class="btn btn-primary btn-lg btn-block btn-goto">立即访问</a>
<?php else : ?>
<a href="#" title="<?php $this->title() ?>" class="disabled btn btn-primary btn-lg btn-block btn-goto">这篇是站内文章哦~</a>
<?php endif; ?>
</div>
</div>
</div>
<?php if ($this->is('post')) :
$this->related(6, count($this->tags) > 0 ? 'tag' : 'author')->to($item);
if ($item->have()) : ?>
<div class="post-related card card-xl mt-4 ">
<div class="card-header">
<div class="related-header">
<div class="related-icon"></div>
<div class="h4">猜你喜欢</div>
</div>
</div>
<div class="card-body">
<div class="row g-2 g-md-3 list-grid list-grid-padding">
<?php while ($item->next()) : ?>
<div class="col-12 col-md-6">
<div class="list-item block">
<div href="<?php $item->permalink(); ?>" title="点击查看详情" class="media w-36 rounded-circle">
<img src="<?php $this->options->themeUrl('/assets/image/default.gif'); ?>" data-src="<?php $item->fields->logo(); ?>" class="media-content lazyload" />
</div>
<div href="<?php $item->fields->url(); ?>" cid="<?php $item->cid(); ?>" class="list-content" title="<?php $item->fields->text(); ?>">
<div class="list-body">
<div class="list-title text-md h-1x"><?php $item->title(); ?></div>
<div class="list-desc text-xx text-muted mt-1">
<div class="h-1x"><?php $item->fields->text(); ?></div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
<? endif;
endif; ?>
</div>
<? endif;
endif; ?>
</div>
</div>
</div>
</div>
</main>
Expand Down

0 comments on commit a473ce9

Please sign in to comment.