Подготовить сайт к запуску

This commit is contained in:
2026-05-17 19:09:30 +03:00
parent ebea196828
commit dcdc040918
47 changed files with 2456 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
import Link from 'next/link';
import { notFound } from 'next/navigation';
import { formatDate, getArticleBySlug, getArticles } from '../../../lib/articles';
export function generateStaticParams() {
return getArticles().map((article) => ({ slug: article.slug }));
}
export async function generateMetadata({ params }) {
const { slug } = await params;
const article = getArticleBySlug(decodeURIComponent(slug));
if (!article) {
return { title: 'Статья не найдена' };
}
return {
title: `${article.title} | ProgCode.Ru`,
description: article.excerpt,
};
}
export default async function ArticlePage({ params }) {
const { slug } = await params;
const article = getArticleBySlug(decodeURIComponent(slug));
if (!article) {
notFound();
}
return (
<main>
<article className="article-page">
<nav className="top-nav" aria-label="Навигация">
<Link href="/">Все статьи</Link>
</nav>
<header className="article-hero">
<div className="article-hero__text">
<div className="meta-line">
<time dateTime={article.date}>{formatDate(article.date)}</time>
<span>{article.author}</span>
<span>{article.readingMinutes} мин</span>
</div>
<h1>{article.title}</h1>
<div className="tag-list">
{article.categories.map((category) => (
<span key={category}>{category}</span>
))}
</div>
</div>
<img src={article.cover} alt="" />
</header>
<div className="article-content" dangerouslySetInnerHTML={{ __html: article.contentHtml }} />
</article>
</main>
);
}
+282
View File
@@ -0,0 +1,282 @@
:root {
--bg: #f3f0e8;
--paper: #fffdfa;
--ink: #1e252d;
--muted: #64707d;
--line: #d8d0c2;
--accent: #216869;
--accent-2: #b4432a;
--code: #111827;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--ink);
font-family: Arial, Helvetica, sans-serif;
line-height: 1.6;
}
a {
color: inherit;
}
img {
display: block;
max-width: 100%;
}
.site-hero {
min-height: 360px;
background:
linear-gradient(90deg, rgba(20, 24, 28, 0.86), rgba(20, 24, 28, 0.35)),
url('/assets/media/cropped-WallpapersMania.nnm_.ru_vol141-087.jpg') center / cover;
color: #fff;
display: flex;
align-items: flex-end;
}
.site-hero__inner {
width: min(1120px, calc(100% - 40px));
margin: 0 auto;
padding: 72px 0 46px;
}
.eyebrow {
margin: 0 0 10px;
color: var(--accent-2);
font-size: 12px;
font-weight: 700;
letter-spacing: 0;
text-transform: uppercase;
}
.site-hero .eyebrow {
color: #f5b08c;
}
h1,
h2,
h3 {
line-height: 1.15;
margin: 0;
}
.site-hero h1 {
font-size: clamp(44px, 8vw, 82px);
}
.site-description {
max-width: 680px;
margin: 18px 0 0;
color: #e5e7eb;
font-size: 20px;
}
.articles-shell {
width: min(1120px, calc(100% - 32px));
margin: 34px auto 64px;
}
.articles-header,
.top-nav,
.meta-line,
.tag-list {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.articles-header {
justify-content: space-between;
margin-bottom: 20px;
}
.articles-header h2 {
font-size: 34px;
}
.articles-header > span,
.meta-line {
color: var(--muted);
font-size: 14px;
}
.article-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 18px;
}
.article-card {
min-height: 100%;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--paper);
text-decoration: none;
transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.article-card:hover {
border-color: #9f8f7a;
box-shadow: 0 12px 30px rgba(39, 33, 25, 0.12);
transform: translateY(-2px);
}
.article-card > img {
width: 100%;
aspect-ratio: 16 / 9;
object-fit: cover;
border-bottom: 1px solid var(--line);
background: #fff;
}
.article-card__body {
padding: 18px;
}
.article-card h3 {
margin-top: 10px;
font-size: 22px;
}
.article-card p {
color: var(--muted);
}
.tag-list span {
border: 1px solid #c5bba9;
border-radius: 999px;
padding: 4px 10px;
background: #f8f5ee;
color: #5c4a37;
font-size: 13px;
}
.article-page {
width: min(1040px, calc(100% - 32px));
margin: 0 auto 72px;
}
.top-nav {
padding: 22px 0;
}
.top-nav a {
color: var(--accent);
font-weight: 700;
text-decoration: none;
}
.article-hero {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
gap: 28px;
align-items: center;
padding: 28px 0 34px;
border-bottom: 1px solid var(--line);
}
.article-hero h1 {
margin: 14px 0 18px;
font-size: clamp(34px, 6vw, 58px);
}
.article-hero > img {
width: 100%;
border: 1px solid var(--line);
border-radius: 8px;
background: #fff;
}
.article-content {
max-width: 820px;
margin: 34px auto 0;
font-size: 18px;
}
.article-content h2 {
margin: 42px 0 14px;
font-size: 30px;
}
.article-content h3 {
margin: 34px 0 12px;
font-size: 24px;
}
.article-content p,
.article-content ul,
.article-content ol {
margin: 0 0 20px;
}
.article-content a {
color: var(--accent);
text-decoration-thickness: 1px;
text-underline-offset: 3px;
}
.article-content figure {
margin: 28px 0;
}
.article-content figure img {
width: 100%;
border: 1px solid var(--line);
border-radius: 8px;
background: #fff;
}
.article-content figcaption {
margin-top: 8px;
color: var(--muted);
font-size: 14px;
}
.article-content pre {
overflow-x: auto;
border-radius: 8px;
margin: 26px 0;
padding: 18px 20px;
background: var(--code);
color: #e5e7eb;
font-size: 15px;
line-height: 1.55;
}
.article-content code {
font-family: SFMono-Regular, Menlo, Consolas, monospace;
}
.article-content :not(pre) > code {
border-radius: 4px;
padding: 2px 5px;
background: #ede6da;
color: #663c1f;
font-size: 0.92em;
}
@media (max-width: 760px) {
.site-hero {
min-height: 320px;
}
.site-description {
font-size: 17px;
}
.article-hero {
grid-template-columns: 1fr;
}
.article-content {
font-size: 16px;
}
}
+38
View File
@@ -0,0 +1,38 @@
import './globals.css';
import Script from 'next/script';
export const metadata = {
title: 'ProgCode.Ru - блог программиста',
description: 'Статьи о PHP, Bitrix, JavaScript, D, Windows и практических задачах разработки.',
};
export default function RootLayout({ children }) {
return (
<html lang="ru">
<body>
<Script id="yandex-metrika" strategy="afterInteractive">
{`
(function(m,e,t,r,i,k,a){
m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
})(window, document,'script','https://mc.yandex.ru/metrika/tag.js?id=109268613', 'ym');
ym(109268613, 'init', {ssr:true, webvisor:true, clickmap:true, ecommerce:"dataLayer", referrer: document.referrer, url: location.href, accurateTrackBounce:true, trackLinks:true});
`}
</Script>
<noscript>
<div>
<img
src="https://mc.yandex.ru/watch/109268613"
style={{ position: 'absolute', left: '-9999px' }}
alt=""
/>
</div>
</noscript>
{children}
</body>
</html>
);
}
+51
View File
@@ -0,0 +1,51 @@
import Link from 'next/link';
import { formatDate, getArticles } from '../lib/articles';
export default function HomePage() {
const articles = getArticles();
return (
<main>
<section className="site-hero">
<div className="site-hero__inner">
<p className="eyebrow">Личный блог программиста</p>
<h1>ProgCode.Ru</h1>
<p className="site-description">
PHP, Bitrix, JavaScript, D, Windows и практические заметки из ежедневной разработки.
</p>
</div>
</section>
<section className="articles-shell" aria-label="Список статей">
<div className="articles-header">
<div>
<p className="eyebrow">Материалы</p>
<h2>Статьи</h2>
</div>
<span>{articles.length} записей</span>
</div>
<div className="article-grid">
{articles.map((article) => (
<Link key={article.slug} className="article-card" href={`/articles/${encodeURIComponent(article.slug)}`}>
<img src={article.cover} alt="" />
<div className="article-card__body">
<div className="meta-line">
<time dateTime={article.date}>{formatDate(article.date)}</time>
<span>{article.readingMinutes} мин</span>
</div>
<h3>{article.title}</h3>
<p>{article.excerpt}</p>
<div className="tag-list">
{article.categories.map((category) => (
<span key={category}>{category}</span>
))}
</div>
</div>
</Link>
))}
</div>
</section>
</main>
);
}