Publish Hardnerd image advertisement in article content

This commit is contained in:
Codex 2026-10-30 19:01:48 +08:00
parent a5c5540b97
commit f0a0f34d8b
5 changed files with 36 additions and 0 deletions

8
config/advertising.php Normal file
View File

@ -0,0 +1,8 @@
<?php
return [
'hn' => [
'enabled' => env('HN_AD_ENABLED', true),
'url' => env('HN_AD_URL', 'https://hardnerd.net/'),
],
];

View File

@ -0,0 +1,14 @@
.hn-article-ad {
position: relative;
min-width: 0;
aspect-ratio: 2.45;
margin: 20px 0;
overflow: hidden;
border: 1px solid #181b1e;
border-radius: 12px;
background: #181b1e;
}
.article-ad-group .hn-article-ad { margin: 0; }
.hn-image-ad__link { position: absolute; inset: 0; display: block; }
.hn-image-ad__link img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hn-image-ad__link:focus-visible { outline: 3px solid #b4f047; outline-offset: -4px; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -0,0 +1,12 @@
@if (config('advertising.hn.enabled') && config('advertising.hn.url') && is_file(public_path('images/ads/hn-ad-site-style-20261028.png')))
@once
@push('styles')
<link rel="stylesheet" href="/css/hn-article-ad.css?v={{ filemtime(public_path('css/hn-article-ad.css')) }}">
@endpush
@endonce
<aside class="hn-article-ad hn-image-ad" aria-label="HN 图片广告">
<a class="hn-image-ad__link" href="{{ config('advertising.hn.url') }}" target="_blank" rel="sponsored noopener noreferrer" aria-label="广告:了解 Hardnerd 网络服务(新窗口打开)">
<img src="/images/ads/hn-ad-site-style-20261028.png?v={{ filemtime(public_path('images/ads/hn-ad-site-style-20261028.png')) }}" alt="Hardnerd 广告:探索全球网络无限可能,了解 HN" width="1962" height="802">
</a>
</aside>
@endif

2
resources/views/pages/articles/default/show.blade.php Executable file → Normal file
View File

@ -77,6 +77,8 @@
</div> </div>
@include('components.hn-article-ad')
<div class="post-tags mt-3 mt-md-4"> <div class="post-tags mt-3 mt-md-4">
<div class=""> <div class="">
@foreach($oArticle->oTags as $oTag) @foreach($oArticle->oTags as $oTag)