blog module | blog archive, blog single(part)

pull/1/head
parent 86f53f07e2
commit 869f2de003
  1. 2
      README.md
  2. 183
      wp-content/themes/cosmopet/functions.php
  3. 1
      wp-content/themes/cosmopet/global-functions/cache-functions.php
  4. 2
      wp-content/themes/cosmopet/global-functions/core-functions.php
  5. 2
      wp-content/themes/cosmopet/home.php
  6. 439
      wp-content/themes/cosmopet/modules/blog/components/archive/assets/css/gp-style-desktop.css
  7. 28
      wp-content/themes/cosmopet/modules/blog/components/archive/assets/css/gp-style-tablet.css
  8. 13
      wp-content/themes/cosmopet/modules/blog/components/archive/component-controller.php
  9. 498
      wp-content/themes/cosmopet/modules/blog/components/archive/component-template.twig
  10. BIN
      wp-content/themes/cosmopet/modules/blog/components/author-banner/assets/img/author-card-mb.png
  11. BIN
      wp-content/themes/cosmopet/modules/blog/components/author-banner/assets/img/author-card.png
  12. BIN
      wp-content/themes/cosmopet/modules/blog/components/author-banner/assets/img/star-1.png
  13. BIN
      wp-content/themes/cosmopet/modules/blog/components/author-banner/assets/img/star-2.png
  14. 14
      wp-content/themes/cosmopet/modules/blog/components/author-banner/component-template.twig
  15. BIN
      wp-content/themes/cosmopet/modules/blog/components/editorial/assets/img/discount-bg-sm.png
  16. BIN
      wp-content/themes/cosmopet/modules/blog/components/editorial/assets/img/discount-bg.png
  17. BIN
      wp-content/themes/cosmopet/modules/blog/components/editorial/assets/img/editorial-card.png
  18. BIN
      wp-content/themes/cosmopet/modules/blog/components/editorial/assets/img/editorial-head-icon.png
  19. BIN
      wp-content/themes/cosmopet/modules/blog/components/editorial/assets/img/editorial-head-star.png
  20. 12
      wp-content/themes/cosmopet/modules/blog/components/editorial/component-controller.php
  21. 38
      wp-content/themes/cosmopet/modules/blog/components/editorial/component-template.twig
  22. 166
      wp-content/themes/cosmopet/modules/blog/components/featured-slider/assets/css/gp-style-desktop.css
  23. 32
      wp-content/themes/cosmopet/modules/blog/components/featured-slider/assets/css/gp-style-tablet.css
  24. 12
      wp-content/themes/cosmopet/modules/blog/components/featured-slider/component-controller.php
  25. 122
      wp-content/themes/cosmopet/modules/blog/components/featured-slider/component-template.twig
  26. 21
      wp-content/themes/cosmopet/modules/blog/components/most-read/component-controller.php
  27. 28
      wp-content/themes/cosmopet/modules/blog/components/most-read/component-template.twig
  28. 21
      wp-content/themes/cosmopet/modules/blog/components/news-list/assets/js/posts-ajax.js
  29. 38
      wp-content/themes/cosmopet/modules/blog/components/news-list/component-ajax-controller.php
  30. 22
      wp-content/themes/cosmopet/modules/blog/components/news-list/component-template.twig
  31. 0
      wp-content/themes/cosmopet/modules/blog/components/single/assets/css/gp-style-desktop.css
  32. 0
      wp-content/themes/cosmopet/modules/blog/components/single/assets/css/gp-style-mobile.css
  33. 0
      wp-content/themes/cosmopet/modules/blog/components/single/assets/css/gp-style-tablet.css
  34. 0
      wp-content/themes/cosmopet/modules/blog/components/single/component-ajax-controller.php
  35. 6
      wp-content/themes/cosmopet/modules/blog/components/single/component-controller.php
  36. 49
      wp-content/themes/cosmopet/modules/blog/components/single/component-template.twig
  37. 0
      wp-content/themes/cosmopet/modules/blog/components/themes/assets/css/gp-style-desktop.css
  38. 0
      wp-content/themes/cosmopet/modules/blog/components/themes/assets/css/gp-style-mobile.css
  39. 0
      wp-content/themes/cosmopet/modules/blog/components/themes/assets/css/gp-style-tablet.css
  40. 19
      wp-content/themes/cosmopet/modules/blog/components/themes/component-controller.php
  41. 15
      wp-content/themes/cosmopet/modules/blog/components/themes/component-template.twig
  42. 139
      wp-content/themes/cosmopet/modules/blog/editor-blocks/texts/assets/css/style.css
  43. 37
      wp-content/themes/cosmopet/modules/blog/editor-blocks/texts/editor-block-controller.php
  44. 4
      wp-content/themes/cosmopet/modules/blog/editor-blocks/texts/editor-block-template.twig
  45. 33
      wp-content/themes/cosmopet/modules/blog/module-controller.php
  46. 87
      wp-content/themes/cosmopet/modules/example/assets/css/gp-style-desktop.css
  47. 0
      wp-content/themes/cosmopet/modules/example/assets/css/gp-style-mobile.css
  48. 32
      wp-content/themes/cosmopet/modules/example/assets/css/gp-style-tablet.css
  49. 4
      wp-content/themes/cosmopet/modules/example/assets/css/gp-style-ultra.css
  50. 11
      wp-content/themes/cosmopet/modules/example/assets/css/gp-style-xl.css
  51. 0
      wp-content/themes/cosmopet/modules/example/components/example/assets/css/gp-style-desktop.css
  52. 0
      wp-content/themes/cosmopet/modules/example/components/example/assets/css/gp-style-mobile.css
  53. 0
      wp-content/themes/cosmopet/modules/example/components/example/assets/css/gp-style-tablet.css
  54. 4
      wp-content/themes/cosmopet/modules/example/components/example/component-ajax-controller.php
  55. 12
      wp-content/themes/cosmopet/modules/example/components/example/component-controller.php
  56. 33
      wp-content/themes/cosmopet/modules/example/components/example/component-template.twig
  57. 0
      wp-content/themes/cosmopet/modules/example/module-ajax-controller.php
  58. 0
      wp-content/themes/cosmopet/modules/example/module-controller.php
  59. 0
      wp-content/themes/cosmopet/modules/example/module.template.twig
  60. 2914
      wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-full.css
  61. 1
      wp-content/themes/cosmopet/modules/layout/module.template.twig
  62. 6
      wp-content/themes/cosmopet/single-post.php

@ -1,2 +0,0 @@
# cosmopet-architecture

@ -1,4 +1,55 @@
<?php <?php
// requere once вместо include использовать!
// доделать example module и component
require_once __DIR__ . '/vendor/autoload.php';
// Initialize Timber.
Timber\Timber::init();
Timber::$dirname = [
[
'modules',
],
];
add_theme_support('post-thumbnails');
//Подруключение всех ajax controller если запрос сделан по ajax
$modulesDir = __DIR__ . '/modules';
// Функция для рекурсивного подключения файлов
function requireAjaxControllers($baseDir) {
$modules = glob($baseDir . '/*', GLOB_ONLYDIR);
foreach ($modules as $module) {
$moduleController = $module . '/module-ajax-controller.php';
if (file_exists($moduleController)) {
require_once $moduleController;
}
$componentsDir = $module . '/components';
if (is_dir($componentsDir)) {
$components = glob($componentsDir . '/*', GLOB_ONLYDIR);
foreach ($components as $component) {
$componentController = $component . '/component-ajax-controller.php';
if (file_exists($componentController)) {
require_once $componentController;
}
}
}
}
}
if( wp_doing_ajax() ){
requireAjaxControllers($modulesDir);
}
function includeFilesFromFolder($folder) { function includeFilesFromFolder($folder) {
// Проверяем, существует ли папка // Проверяем, существует ли папка
@ -24,23 +75,7 @@ function includeFilesFromFolder($folder) {
} }
} }
// function enqueue_css($directory) { // Подключает модуль из папки /modules/
// // Check if the directory exists
// if (!is_dir($directory)) {
// return; // Exit if the directory doesn't exist
// }
// // Get all CSS files in the specified directory
// $css_files = glob($directory . '/*.css');
// // Enqueue each CSS file
// foreach ($css_files as $css_file) {
// // Get the file name without the directory
// $file_name = basename($css_file);
// // Enqueue the CSS file
// wp_enqueue_style($file_name, get_template_directory_uri() . '/' . $directory . '/' . $file_name);
// }
// }
function include_module($module_name) { function include_module($module_name) {
// Убедитесь, что имя модуля не пустое // Убедитесь, что имя модуля не пустое
if (empty($module_name)) { if (empty($module_name)) {
@ -50,17 +85,51 @@ function include_module($module_name) {
// Получаем путь к каталогу модуля // Получаем путь к каталогу модуля
$module_dir = get_template_directory() . '/modules/' . $module_name; $module_dir = get_template_directory() . '/modules/' . $module_name;
// Регистрируем стили и скрипты // Регистрируем стили и скрипты
add_action('wp_enqueue_scripts', function() use ($module_name, $module_dir) { add_action('wp_enqueue_scripts', function() use ($module_name, $module_dir) {
// Подключаем стили // Подключаем стили
$css_dir = $module_dir . '/assets/css'; $css_dir = $module_dir . '/assets/css';
if (is_dir($css_dir)) { if (is_dir($css_dir)) {
$css_files = scandir($css_dir); $css_files = scandir($css_dir);
// Приоритетные файлы
$priority_files = [
'normalize.css',
'gp-style-core.css',
'gp-style-desktop.css',
'gp-style-tablet.css',
'gp-style-mobile.css'
];
// Подключаем приоритетные файлы в заданном порядке
foreach ($priority_files as $priority_file) {
$file_path = $css_dir . '/' . $priority_file;
if (file_exists($file_path)) {
wp_enqueue_style(
$module_name . '-' . pathinfo($priority_file, PATHINFO_FILENAME),
get_template_directory_uri() . '/modules/' . $module_name . '/assets/css/' . $priority_file,
[],
filemtime($file_path)
);
}
}
// Подключаем остальные CSS-файлы
foreach ($css_files as $css_file) { foreach ($css_files as $css_file) {
if (pathinfo($css_file, PATHINFO_EXTENSION) === 'css' && $css_file !== '.' && $css_file !== '..') { if (
pathinfo($css_file, PATHINFO_EXTENSION) === 'css' &&
$css_file !== '.' &&
$css_file !== '..' &&
!in_array($css_file, $priority_files)
) {
$file_path = $css_dir . '/' . $css_file;
wp_enqueue_style( wp_enqueue_style(
$module_name . '-' . pathinfo($css_file, PATHINFO_FILENAME), $module_name . '-' . pathinfo($css_file, PATHINFO_FILENAME),
get_template_directory_uri() . '/modules/' . $module_name . '/assets/css/' . $css_file get_template_directory_uri() . '/modules/' . $module_name . '/assets/css/' . $css_file,
[],
filemtime($file_path)
); );
} }
} }
@ -71,12 +140,17 @@ function include_module($module_name) {
if (is_dir($js_dir)) { if (is_dir($js_dir)) {
$js_files = scandir($js_dir); $js_files = scandir($js_dir);
foreach ($js_files as $js_file) { foreach ($js_files as $js_file) {
if (pathinfo($js_file, PATHINFO_EXTENSION) === 'js' && $js_file !== '.' && $js_file !== '..') { if (
pathinfo($js_file, PATHINFO_EXTENSION) === 'js' &&
$js_file !== '.' &&
$js_file !== '..'
) {
$file_path = $js_dir . '/' . $js_file;
wp_enqueue_script( wp_enqueue_script(
$module_name . '-' . pathinfo($js_file, PATHINFO_FILENAME), $module_name . '-' . pathinfo($js_file, PATHINFO_FILENAME),
get_template_directory_uri() . '/modules/' . $module_name . '/assets/js/' . $js_file, get_template_directory_uri() . '/modules/' . $module_name . '/assets/js/' . $js_file,
array('jquery'), ['jquery'],
null, filemtime($file_path),
true true
); );
} }
@ -88,14 +162,9 @@ function include_module($module_name) {
// Подключаем контроллер модуля // Подключаем контроллер модуля
$module_controller = $module_dir . '/module-controller.php'; $module_controller = $module_dir . '/module-controller.php';
if (file_exists($module_controller)) { if (file_exists($module_controller)) {
include $module_controller; include_once $module_controller ;
} }
// Подключаем AJAX контроллер модуля
$module_ajax_controller = $module_dir . '/module-ajax-controller.php';
if (file_exists($module_ajax_controller)) {
include $module_ajax_controller;
}
} }
function include_component($module_name, $component_name) { function include_component($module_name, $component_name) {
@ -114,11 +183,31 @@ function include_component($module_name, $component_name) {
if (is_dir($css_dir)) { if (is_dir($css_dir)) {
$css_files = scandir($css_dir); $css_files = scandir($css_dir);
foreach ($css_files as $css_file) { // Приоритетные файлы в нужном порядке
if (pathinfo($css_file, PATHINFO_EXTENSION) === 'css' && $css_file !== '.' && $css_file !== '..') { $priority_files = [
'gp-style-core.css',
'gp-style-desktop.css',
'gp-style-tablet.css',
'gp-style-mobile.css'
];
// Подключаем приоритетные файлы в заданном порядке
foreach ($priority_files as $priority_file) {
$file_path = $css_dir . '/' . $priority_file;
if (file_exists($file_path)) {
$handle = "{$module_name}-{$component_name}-" . pathinfo($priority_file, PATHINFO_FILENAME);
$src = get_template_directory_uri() . "/modules/{$module_name}/components/{$component_name}/assets/css/{$priority_file}";
wp_enqueue_style($handle, $src, [], filemtime($file_path)); // Используем filemtime для версии
}
}
wp_enqueue_style($module_name . '-' . $component_name . '-' . pathinfo($css_file, PATHINFO_FILENAME), get_template_directory_uri() . '/modules/' . $module_name . '/components/' . $component_name . '/assets/css/' . $css_file); // Подключаем остальные CSS-файлы
foreach ($css_files as $css_file) {
if (pathinfo($css_file, PATHINFO_EXTENSION) === 'css' && !in_array($css_file, $priority_files)) {
$file_path = $css_dir . '/' . $css_file;
$handle = "{$module_name}-{$component_name}-" . pathinfo($css_file, PATHINFO_FILENAME);
$src = get_template_directory_uri() . "/modules/{$module_name}/components/{$component_name}/assets/css/{$css_file}";
wp_enqueue_style($handle, $src, [], filemtime($file_path));
} }
} }
} }
@ -128,37 +217,24 @@ function include_component($module_name, $component_name) {
if (is_dir($js_dir)) { if (is_dir($js_dir)) {
$js_files = scandir($js_dir); $js_files = scandir($js_dir);
foreach ($js_files as $js_file) { foreach ($js_files as $js_file) {
if (pathinfo($js_file, PATHINFO_EXTENSION) === 'js') {
if (pathinfo($js_file, PATHINFO_EXTENSION) === 'js' && $js_file !== '.' && $js_file !== '..') { $file_path = $js_dir . '/' . $js_file;
wp_enqueue_script($module_name . '-' . $component_name . '-' . pathinfo($js_file, PATHINFO_FILENAME), get_template_directory_uri() . '/modules/' . $module_name . '/components/' . $component_name . '/assets/js/' . $js_file, array('jquery'), null, true); $handle = "{$module_name}-{$component_name}-" . pathinfo($js_file, PATHINFO_FILENAME);
$src = get_template_directory_uri() . "/modules/{$module_name}/components/{$component_name}/assets/js/{$js_file}";
wp_enqueue_script($handle, $src, ['jquery'], filemtime($file_path), true);
} }
} }
} }
}); });
$component_controller = $component_dir . '/component-controller.php'; $component_controller = $component_dir . '/component-controller.php';
if (file_exists($component_controller)) { if (file_exists($component_controller)) {
include $component_controller; include_once $component_controller ;
}
$component_ajax_controller = $component_dir . '/component-ajax-controller.php';
if (file_exists($component_ajax_controller)) {
include $component_ajax_controller;
}
} }
require_once __DIR__ . '/vendor/autoload.php';
// Initialize Timber.
Timber\Timber::init();
Timber::$dirname = [ }
[
'modules',
],
];
includeFilesFromFolder(get_template_directory() . '/global-functions'); includeFilesFromFolder(get_template_directory() . '/global-functions');
@ -169,5 +245,10 @@ add_filter('timber/context', function($context) {
}); });
$modules_path = get_template_directory() . '/modules/*/editor-blocks/*/editor-block-controller.php';
foreach (glob($modules_path) as $file) {
require_once $file; // Подключаем каждый найденный файл
}
include_module('layout'); include_module('layout');

@ -1,3 +1,5 @@
<?php <?php
include_module('blog');
include_component('blog', 'archive'); include_component('blog', 'archive');
?> ?>

@ -1,442 +1,3 @@
/* Home */ /* Home */
.home {
padding: 140px 0 68px;
}
.home-title {
font-size: 82px;
font-weight: bold;
line-height: 96px;
color: var(--main_white);
margin-bottom: 16px;
}
.home-description {
font-size: 32px;
font-weight: bold;
line-height: 40px;
color: var(--main_white);
text-transform: uppercase;
margin-bottom: 68px;
}
/* Home end */
/* Anons */
.anons {
background: var(--main_white);
border-radius: 60px;
padding: 51px 0;
}
.anons-theme__title {
color: var(--main_black);
font-size: 24px;
font-weight: bold;
line-height: 28px;
text-transform: uppercase;
margin-bottom: 20px;
}
.anons-theme {
margin-bottom: 60px;
}
.anons-theme ul {
max-width: 1022px;
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.anons-theme ul a {
font-size: 20px;
font-weight: 600;
line-height: 24px;
color: var(--main_black);
padding: 4px 24px;
border: 1px solid #000;
border-radius: 20px;
}
.anons-theme ul a:hover,
.anons-theme ul a.active {
background: var(--main_black);
color: var(--main_white);
}
.anons-best {
margin-bottom: 60px;
}
.anons-best__title {
font-size: 36px;
line-height: 40px;
font-weight: bold;
color: var(--main_black);
margin-bottom: 20px;
}
.anons-best__card-wrap {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 24px;
}
.anons-best__card {
padding-top: 293px;
border-radius: 48px;
overflow: hidden;
position: relative;
z-index: 1;
}
.anons-best__card.light {
padding-top: 0;
border-radius: 0;
}
.anons-best__card .main-img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 360px;
z-index: -1;
}
.anons-best__card .main-img img {
width: 100%;
height: 100%;
object-fit: cover;
}
.anons-best__card.light .main-img {
position: static;
height: 265px;
}
.anons-best__card.light .main-img img {
border-radius: 30px;
}
.anons-best__card-alerts {
position: absolute;
top: 21px;
left: 17px;
width: calc(100% - 34px);
display: flex;
flex-wrap: wrap;
gap: 7px;
z-index: 1;
}
.anons-best__card-alerts li {
padding: 6px 8px;
font-size: 16px;
line-height: 20px;
font-weight: 500;
color: var(--background);
background: var(--main_black);
border-radius: 30px;
}
.anons-best__card-body {
background: var(--accent-1);
padding: 30px 17px 22px;
border-radius: 48px 48px 0 0;
color: var(--main_white);
position: relative;
height: 100%;
}
.anons-best__card.light .anons-best__card-body {
background: transparent;
color: var(--main_black);
padding: 12px 0 34px;
}
.anons-best__card-body__title {
font-size: 28px;
font-weight: bold;
line-height: 32px;
text-transform: uppercase;
margin-bottom: 14px;
}
.anons-best__card.light .anons-best__card-body__title {
font-size: 26px;
}
.anons-best__card-body__datas {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px 10px;
max-width: 264px;
}
.anons-best__card.light .anons-best__card-body__datas {
color: var(--placeholder);
}
.anons-best__card-body__datas p {
font-size: 14px;
line-height: 16px;
font-weight: 500;
}
.anons-best__card-body__datas ul {
display: flex;
align-items: center;
gap: 10px;
}
.anons-best__card-body__datas ul li {
display: flex;
align-items: center;
gap: 4px;
font-size: 14px;
line-height: 16px;
font-weight: 500;
}
.anons-best__card-body__datas ul .logo img {
width: 24px;
height: 24px;
border-radius: 50%;
object-fit: cover;
}
.anons-article {
margin-bottom: 40px;
}
.anons-article__title {
font-size: 36px;
line-height: 40px;
font-weight: bold;
color: var(--main_black);
margin-bottom: 20px;
}
.anons-article__card-wrap {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 40px 25px;
}
.anons-article__more-link {
display: flex;
align-items: center;
justify-content: center;
}
.anons-article__more-link a {
background: var(--accent-3);
color: var(--main_white);
border-radius: 20px;
border: 1px solid var(--main_white);
padding: 16px 24px;
font-size: 20px;
font-weight: 600;
line-height: 24px;
text-transform: uppercase;
}
/* Anons end */
/* Author */
.author {
padding: 111px 0 105px;
}
.author-content {
max-width: 1022px;
margin: 0 auto;
background: #CAFF81;
border-radius: 60px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 35px 42px 35px 209px;
position: relative;
box-shadow: 6px 9px 20px rgba(0, 0, 0, 15%);
}
.author-content__star-1 {
position: absolute;
width: 74px;
top: 18px;
left: -15px;
transform: translateX(-100%);
}
.author-content__star-2 {
position: absolute;
top: 28px;
right: -24px;
transform: translateX(100%);
width: 37px;
}
.author-content__img {
position: absolute;
left: 9px;
top: -43px;
width: 167px;
}
.author-content__img.mb {
display: none;
}
.author-content__title {
color: var(--main_black);
font-size: 36px;
font-weight: bold;
line-height: 40px;
}
.author-content__link {
border-radius: 20px;
background: var(--main_black);
border: 1px solid var(--main_white);
padding: 15px 24px;
font-size: 20px;
font-weight: 600;
line-height: 24px;
color: var(--main_white);
flex-shrink: 0;
}
/* Author end */
/* Editorial */
.editorial {
padding-bottom: 68px;
}
.editorial-head {
position: relative;
z-index: 1;
max-width: 841px;
margin-bottom: 37px;
}
.editorial-head__title {
font-size: 82px;
line-height: 96px;
font-weight: bold;
color: var(--main_white);
text-transform: uppercase;
}
.editorial-head__img {
position: absolute;
z-index: -1;
top: -14px;
right: -20px;
width: 221px;
}
.editorial-head__star {
position: absolute;
top: 8.26px;
right: -13.5px;
transform: translateX(100%);
width: 87.5px;
}
.editorial-card__wrap {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 31px 25px;
position: relative;
z-index: 1;
}
.editorial-card {
border: 2px solid var(--creme-white);
border-radius: 30px;
display: flex;
align-items: stretch;
overflow: hidden;
background: var(--linear);
backdrop-filter: blur(28px);
}
.editorial-card .main-img {
min-height: 282px;
width: 207px;
border-radius: 29px;
overflow: hidden;
flex-shrink: 0;
}
.editorial-card .main-img img {
width: 100%;
height: 100%;
object-fit: cover;
}
.editorial-card__content {
padding: 42px 19px 19px 35px;
}
.editorial-card__content-alerts {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 7px;
margin-bottom: 17px;
}
.editorial-card__content-alerts a {
background: var(--main_black);
border-radius: 16px;
padding: 6px 8px;
font-size: 16px;
font-weight: 500;
line-height: 20px;
color: var(--background);
}
.editorial-card__content-title {
font-size: 28px;
font-weight: bold;
line-height: 32px;
color: var(--grey-black);
text-transform: uppercase;
margin-bottom: 17px;
}
.editorial-card__content-data {
display: flex;
flex-wrap: wrap;
gap: 5px 16px;
color: var(--interface_hover);
font-size: 16px;
font-weight: 500;
line-height: 20px;
}
.editorial-card__content-data ul {
display: flex;
align-items: center;
gap: 16px;
}
.editorial-card__content-data li {
display: flex;
align-items: center;
gap: 5px;
}
.editorial-card__content-data .logo img {
width: 24px;
height: 24px;
border-radius: 50%;
object-fit: cover;
}
/* Editorial end */ /* Editorial end */

@ -1,32 +1,4 @@
/* Стили для планшетов */ /* Стили для планшетов */
@media only screen and (max-width: 992px) { @media only screen and (max-width: 992px) {
.header-navs {
display: none;
}
.header-container {
height: 56px;
padding: 0;
}
.header-bars {
display: flex;
align-items: center;
justify-content: center;
}
.header-logo {
font-size: 16px;
line-height: 20px;
gap: 8px;
}
.header-logo img {
width: 31px;
flex-shrink: 0;
}
.header-lang {
display: none;
}
} }

@ -1,5 +1,18 @@
<?php <?php
include_component('blog', 'featured-slider'); include_component('blog', 'featured-slider');
include_component('blog', 'themes');
include_component('blog', 'most-read');
include_component('blog', 'news-list');
include_component('blog', 'editorial');
wp_localize_script('blog-archive-posts-ajax-js', 'ajax', array(
'ajax_url' => admin_url('admin-ajax.php'),
));
$context = Timber::get_context(); $context = Timber::get_context();
$context['post_count'] = wp_count_posts()->publish; // Количество опубликованных постов
$context['total_pages'] = ceil($context['post_count'] / get_option('posts_per_page')); // Общее количество страниц
Timber::render('blog/components/archive/component-template.twig', $context); Timber::render('blog/components/archive/component-template.twig', $context);

@ -16,496 +16,34 @@
<!-- Anons --> <!-- Anons -->
<section class="anons"> <section class="anons">
<div class="container"> <div class="container">
<div class="anons-theme"> {% include '/blog/components/themes/component-template.twig' %}
<h3 class="anons-theme__title">Темы:</h3> {% include '/blog/components/most-read/component-template.twig' %}
<ul>
<li>
<a href="#" class="active">ВСЕ</a>
</li>
<li>
<a href="#">ТРЕНДЫ</a>
</li>
<li>
<a href="#">БИОТЕХНОЛОГИИ</a>
</li>
<li>
<a href="#">ОБЗОРЫ</a>
</li>
<li>
<a href="#">ЗДОРОВЬЕ</a>
</li>
<li>
<a href="#">НАУКА</a>
</li>
<li>
<a href="#">ЭКОЛОГИЯ</a>
</li>
<li>
<a href="#">РАЗВИТИЕ</a>
</li>
<li>
<a href="#">ИСТОРИИ</a>
</li>
<li>
<a href="#">BSF</a>
</li>
<li>
<a href="#">ПСИХОЛОГИЯ</a>
</li>
</ul>
</div>
<div class="anons-best">
<h2 class="anons-best__title">САМЫЕ ЧИТАЕМЫЕ:</h2>
<ul class="anons-best__card-wrap">
<li class="anons-best__card">
<ul class="anons-best__card-alerts">
<li>
<a href="#">Обзоры</a>
</li>
<li>
<a href="#">Наука</a>
</li>
</ul>
<a href="#" class="main-img">
<img src="./assets/img/anons-best-card-1.png" alt="">
</a>
<div class="anons-best__card-body">
<a href="#" class="anons-best__card-body__title">Как рассчитать дневную порцию корма для кошки?</a>
<div class="anons-best__card-body__datas">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-white.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-white.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="anons-best__card">
<ul class="anons-best__card-alerts">
<li>
<a href="#">Наука</a>
</li>
</ul>
<a href="#" class="main-img">
<img src="./assets/img/anons-best-card-2.png" alt="">
</a>
<div class="anons-best__card-body">
<a href="#" class="anons-best__card-body__title">Вечно голодная кошка: 8 способов решить проблему</a>
<div class="anons-best__card-body__datas">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-white.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-white.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="anons-best__card">
<ul class="anons-best__card-alerts">
<li>
<a href="#">Обзоры</a>
</li>
<li>
<a href="#">Наука</a>
</li>
</ul>
<a href="#" class="main-img">
<img src="./assets/img/anons-best-card-3.png" alt="">
</a>
<div class="anons-best__card-body">
<a href="#" class="anons-best__card-body__title">Корма для животных на основе энтобелка</a>
<div class="anons-best__card-body__datas">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-white.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-white.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
<div class="anons-article"> <div class="anons-article">
<h2 class="anons-article__title">ВСЕ СТАТЬИ</h2> <h2 class="anons-article__title">ВСЕ СТАТЬИ</h2>
<ul class="anons-article__card-wrap"> <ul class="anons-article__card-wrap">
<li class="anons-best__card light"> {% include '/blog/components/news-list/component-template.twig' %}
<ul class="anons-best__card-alerts"> </ul>
<li> </div>
<a href="#">обзоры</a> {% if total_pages > 1 %}
</li> <form id="ajax-load-blog" data-total="{{ total_pages }}">
</ul> <input type="hidden" name="page_num" id="page_num" value="1">
<a href="#" class="main-img"> <input type="hidden" name="action" value="load_blog_posts">
<img src="./assets/img/anons-article-card-1.png" alt=""> <button class="anons-article__more-link" >
</a> ПОКАЗАТЬ ЕЩЁ
<div class="anons-best__card-body"> </button>
<a href="#" class="anons-best__card-body__title">E-protein: новый белок, изменивший правила игры</a> </form>
<div class="anons-best__card-body__datas"> {% endif %}
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-grey.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-grey.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="anons-best__card light">
<ul class="anons-best__card-alerts">
<li>
<a href="#">Здоровье</a>
</li>
</ul>
<a href="#" class="main-img">
<img src="./assets/img/anons-article-card-2.png" alt="">
</a>
<div class="anons-best__card-body">
<a href="#" class="anons-best__card-body__title">Как совершенствовалась формула Cosmodog</a>
<div class="anons-best__card-body__datas">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-grey.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-grey.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="anons-best__card light">
<ul class="anons-best__card-alerts">
<li>
<a href="#">Экология</a>
</li>
</ul>
<a href="#" class="main-img">
<img src="./assets/img/anons-article-card-3.png" alt="">
</a>
<div class="anons-best__card-body">
<a href="#" class="anons-best__card-body__title">Как выбрать когтеточку: обзор мастхевов для кошки</a>
<div class="anons-best__card-body__datas">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-grey.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-grey.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="anons-best__card light">
<ul class="anons-best__card-alerts">
<li>
<a href="#">BSF</a>
</li>
</ul>
<a href="#" class="main-img">
<img src="./assets/img/anons-article-card-4.png" alt="">
</a>
<div class="anons-best__card-body">
<a href="#" class="anons-best__card-body__title">Вечно голодная кошка: 8 способов решить проблему</a>
<div class="anons-best__card-body__datas">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-grey.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-grey.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="anons-best__card light">
<ul class="anons-best__card-alerts">
<li>
<a href="#">Истории</a>
</li>
</ul>
<a href="#" class="main-img">
<img src="./assets/img/anons-article-card-5.png" alt="">
</a>
<div class="anons-best__card-body">
<a href="#" class="anons-best__card-body__title">Вечно голодная кошка: 8 способов решить проблему</a>
<div class="anons-best__card-body__datas">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-grey.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-grey.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="anons-best__card light">
<ul class="anons-best__card-alerts">
<li>
<a href="#">Наука</a>
</li>
</ul>
<a href="#" class="main-img">
<img src="./assets/img/anons-article-card-6.png" alt="">
</a>
<div class="anons-best__card-body">
<a href="#" class="anons-best__card-body__title">Вечно голодная кошка: 8 способов решить проблему</a>
<div class="anons-best__card-body__datas">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/heart-grey.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-grey.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
<div class="anons-article__more-link">
<a href="#">ПОКАЗАТЬ ЕЩЁ</a>
</div>
</div>
</section> </section>
<!-- Anons end --> <!-- Anons end -->
<!-- Author --> <!-- Author -->
<section class="author"> {% include '/blog/components/author-banner/component-template.twig' %}
<div class="container">
<div class="author-content">
<img src="./assets/img/star-1.png" alt="" class="author-content__star-1">
<img src="./assets/img/star-2.png" alt="" class="author-content__star-2">
<img src="./assets/img/author-card.png" alt="" class="author-content__img">
<img src="./assets/img/author-card-mb.png" alt="" class="author-content__img mb">
<h2 class="author-content__title">ПРЕДЛОЖИТЕ СТАТЬЮ <br>ИЛИ СТАНЬТЕ АВТОРОМ</h2>
<a href="#" class="author-content__link">НАПИШИТЕ НАМ</a>
</div>
</div>
</section>
<!-- Author end --> <!-- Author end -->
<!-- Editorial --> <!-- Editorial -->
<section class="editorial"> {% include '/blog/components/editorial/component-template.twig' %}
<div class="container">
<div class="editorial-head">
<h2 class="editorial-head__title">COSMO тема редакции</h2>
<img src="./assets/img/editorial-head-icon.png" alt="" class="editorial-head__img">
<img src="./assets/img/editorial-head-star.png" alt="" class="editorial-head__star">
</div>
<ul class="editorial-card__wrap">
<li class="editorial-card">
<a href="#" class="main-img">
<img src="./assets/img/editorial-card.png" alt="">
</a>
<div class="editorial-card__content">
<ul class="editorial-card__content-alerts">
<li>
<a href="#">Обзоры</a>
</li>
<li>
<a href="#">Наука</a>
</li>
</ul>
<a href="#" class="editorial-card__content-title">Как рассчитать дневную порцию корма для кошки?</a>
<div class="editorial-card__content-data">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/header-red.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-green.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="editorial-card">
<a href="#" class="main-img">
<img src="./assets/img/editorial-card.png" alt="">
</a>
<div class="editorial-card__content">
<ul class="editorial-card__content-alerts">
<li>
<a href="#">Обзоры</a>
</li>
<li>
<a href="#">Наука</a>
</li>
</ul>
<a href="" class="editorial-card__content-title">Как рассчитать дневную порцию корма для кошки?</a>
<div class="editorial-card__content-data">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/header-red.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-green.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="editorial-card">
<a href="#" class="main-img">
<img src="./assets/img/editorial-card.png" alt="">
</a>
<div class="editorial-card__content">
<ul class="editorial-card__content-alerts">
<li>
<a href="#">Обзоры</a>
</li>
<li>
<a href="#">Наука</a>
</li>
</ul>
<a href="#" class="editorial-card__content-title">Как рассчитать дневную порцию корма для кошки?</a>
<div class="editorial-card__content-data">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/header-red.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-green.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
<li class="editorial-card">
<a href="#" class="main-img">
<img src="./assets/img/editorial-card.png" alt="">
</a>
<div class="editorial-card__content">
<ul class="editorial-card__content-alerts">
<li>
<a href="#">Обзоры</a>
</li>
<li>
<a href="#">Наука</a>
</li>
</ul>
<a href="#" class="editorial-card__content-title">Как рассчитать дневную порцию корма для кошки?</a>
<div class="editorial-card__content-data">
<p>21.10.24</p>
<p>время чтения: 5 минут</p>
<ul>
<li>
<img src="./assets/img/header-red.svg" alt="">
<span>22</span>
</li>
<li>
<img src="./assets/img/msg-green.svg" alt="">
<span>14</span>
</li>
<li class="logo">
<img src="./assets/img/user-logo.png" alt="">
</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
</section>
<!-- Editorial end --> <!-- Editorial end -->
{% endblock %} {% endblock %}

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -0,0 +1,14 @@
{% set current_path = template_path ~ '/modules/blog/components/author-banner' %}
<section class="author">
<div class="container">
<div class="author-content">
<img src="{{ current_path }}/assets/img/star-1.png" alt="" class="author-content__star-1">
<img src="{{ current_path }}/assets/img/star-2.png" alt="" class="author-content__star-2">
<img src="{{ current_path }}/assets/img/author-card.png" alt="" class="author-content__img">
<img src="{{ current_path }}/assets/img/author-card-mb.png" alt="" class="author-content__img mb">
<h2 class="author-content__title">ПРЕДЛОЖИТЕ СТАТЬЮ <br>ИЛИ СТАНЬТЕ АВТОРОМ</h2>
<a href="#" class="author-content__link">НАПИШИТЕ НАМ</a>
</div>
</div>
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

@ -1,2 +1,14 @@
<?php <?php
add_filter('timber/context', function($context) {
$repeater = get_field('editorial', 'options');
if ($repeater) {
foreach ($repeater as &$item) {
if (!empty($item['post'])) {
$item['post'] = Timber::get_post($item['post'], 'BlogPost');
}
}
}
$context['editorial'] = $repeater;
return $context;
});

@ -0,0 +1,38 @@
{% set current_path = template_path ~ '/modules/blog/components/editorial' %}
{% if editorial %}
<section class="editorial">
<div class="container">
<div class="editorial-head">
<h2 class="editorial-head__title">COSMO тема редакции</h2>
<img src="{{ current_path }}/assets/img/editorial-head-icon.png" alt="" class="editorial-head__img">
<img src="{{ current_path }}/assets/img/editorial-head-star.png" alt="" class="editorial-head__star">
</div>
<ul class="editorial-card__wrap">
{% for item in editorial %}
{% set _post = item.post %}
<li class="editorial-card">
<a href="{{_post.link}}" class="main-img">
<img src="{{_post.thumbnail.src}}" alt="{{_post.thumbnail.alt}}">
</a>
<div class="editorial-card__content">
<ul class="editorial-card__content-alerts">
{% for category in _post.categories %}
<li>
<a href="{{ category.link }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
<a href="{{_post.link}}" class="editorial-card__content-title">{{_post.name}}</a>
<div class="editorial-card__content-data">
<p>{{_post.date}}</p>
<p>{{_post.reading_time}}</p>
</div>
</div>
</li>
{% endfor %}
</ul>
</div>
</section>
{% endif %}

@ -1,166 +0,0 @@
.home-swp {
position: relative;
}
.home-swp__btn {
position: absolute;
bottom: 22px;
left: 50%;
transform: translateX(-50%);
z-index: 2;
display: flex;
align-items: center;
gap: 24px;
}
.home-swp__btn button {
border: 1px solid var(--main_black);
background: var(--main_white);
width: 56px;
height: 56px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 20px;
}
.home-swp .swiper-slide:not(.swiper-slide-active) {
height: 0;
overflow: hidden;
}
.home-card {
border-radius: 60px;
overflow: hidden;
display: flex;
align-items: flex-start;
gap: 24px;
position: relative;
}
.home-card.bg-yellow {
background: var(--orange_80);
}
.home-card.bg-green {
background: var(--green_90);
}
.home-card.bg-violet {
background: var(--violet_90);
}
.home-card__img {
width: 395px;
border-radius: 60px;
overflow: hidden;
height: 393px;
flex-shrink: 0;
}
.home-card__img img {
width: 100%;
height: 100%;
object-fit: cover;
}
.home-card__content {
padding: 32px 79px 0 0;
}
.home-card__content-title {
font-size: 36px;
font-weight: bold;
line-height: 40px;
text-transform: uppercase;
max-width: 660px;
margin-bottom: 10px;
color: var(--interface_title);
}
.home-card__content-description {
color: var(--interface_title);
margin-bottom: 10px;
font-size: 20px;
font-weight: 500;
line-height: 24px;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.home-card__content-body {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
}
.home-card__content-body__alerts {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
}
.home-card__content-body__alerts li {
background: var(--interface_hover);
color: var(--background);
border-radius: 16px;
padding: 6px 8px;
font-size: 16px;
font-weight: 500;
line-height: 20px;
}
.home-card__content-body__day {
color: var(--interface_hover);
font-size: 14px;
font-weight: 500;
line-height: 16px;
}
.home-card__content-body__time {
font-size: 14px;
font-weight: 500;
line-height: 16px;
color: var(--interface_hover);
}
.home-card__content-body__data {
display: flex;
align-items: center;
gap: 12px;
}
.home-card__content-body__data>div {
display: flex;
align-items: center;
gap: 4px;
font-size: 14px;
font-weight: 500;
line-height: 16px;
color: var(--interface_hover);
}
.home-card__content-body__data>div .main-img {
width: 32px;
height: 32px;
border-radius: 50%;
object-fit: cover;
}
.home-card__content-body__link {
border: 1px solid #000000;
border-radius: 28px;
background: var(--main_white);
position: absolute;
right: 37px;
bottom: 26px;
padding: 8.5px 16px 12.5px;
font-style: 20px;
font-weight: 500;
line-height: 24px;
}

@ -1,32 +0,0 @@
/* Стили для планшетов */
@media only screen and (max-width: 992px) {
.header-navs {
display: none;
}
.header-container {
height: 56px;
padding: 0;
}
.header-bars {
display: flex;
align-items: center;
justify-content: center;
}
.header-logo {
font-size: 16px;
line-height: 20px;
gap: 8px;
}
.header-logo img {
width: 31px;
flex-shrink: 0;
}
.header-lang {
display: none;
}
}

@ -1,2 +1,14 @@
<?php <?php
add_filter('timber/context', function($context) {
$repeater = get_field('featured', 'options');
if ($repeater) {
foreach ($repeater as &$item) {
if (!empty($item['post'])) {
$item['post'] = Timber::get_post($item['post'], 'BlogPost');
}
}
}
$context['featured'] = $repeater;
return $context;
});

@ -1,4 +1,6 @@
{% set current_path = template_path ~ '/modules/blog/components/featured-slider' %} {% set current_path = template_path ~ '/modules/blog/components/featured-slider' %}
{% if featured %}
<div class="home-swp"> <div class="home-swp">
<div class="home-swp__btn"> <div class="home-swp__btn">
<button class="home-swp__btn-prev"> <button class="home-swp__btn-prev">
@ -10,114 +12,38 @@
</div> </div>
<div class="swiper"> <div class="swiper">
<div class="swiper-wrapper"> <div class="swiper-wrapper">
{% for item in featured %}
{% set _post = item.post %}
<div class="swiper-slide"> <div class="swiper-slide">
<div class="home-card bg-yellow"> <div class="home-card" style="background-color: {{ item.color }}">
<a href="#" class="home-card__img"> <a href="{{_post.link}}" class="home-card__img">
<img src="{{ current_path }}/assets/img/home-card.png" alt=""> <img src="{{_post.thumbnail.src}}" alt="{{_post.thumbnail.alt}}">
</a> </a>
<div class="home-card__content"> <div class="home-card__content">
<a href="#" class="home-card__content-title">Как выбрать когтеточку: обзор мастхевов для вашей <a href="{{_post.link}}" class="home-card__content-title">{{_post.name}}</a>
кошки</a> <p class="home-card__content-description">{{_post.excerpt}}</p>
<p class="home-card__content-description">Простая с виду задача «купить когтеточку» может
оказаться утомительным и дорогим занятием. Типичная ситуация: вы приобрели сразу несколько
вариантов ...</p>
<div class="home-card__content-body"> <div class="home-card__content-body">
<ul class="home-card__content-body__alerts"> <ul class="home-card__content-body__alerts">
<li>Обзоры</li> {% for category in _post.categories %}
<li>Тренды</li> <li>
<a href="{{ category.link }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul> </ul>
<div class="home-card__content-body__day">21.10.24</div> <div class="home-card__content-body__day">{{_post.date}}</div>
<div class="home-card__content-body__time">время чтения: 5 минут</div> <div class="home-card__content-body__time">время чтения: {{_post.reading_time}}</div>
<div class="home-card__content-body__data">
<div> <a href="{{_post.link}}" class="home-card__content-body__link">читать статью</a>
<img src="{{ current_path }}/assets/img/heart.svg" alt="">
<span>22</span>
</div>
<div>
<img src="{{ current_path }}/assets/img/msg.svg" alt="">
<span>22</span>
</div>
<div>
<img src="{{ current_path }}/assets/img/user-logo.png" alt="" class="main-img">
</div>
</div>
<a href="#" class="home-card__content-body__link">читать статью</a>
</div>
</div>
</div>
</div>
<div class="swiper-slide">
<div class="home-card bg-green">
<a href="#" class="home-card__img">
<img src="{{ current_path }}/assets/img/home-card-2.png" alt="">
</a>
<div class="home-card__content">
<a href="#" class="home-card__content-title">Краткая история кормов: от хлебных корок до
лечебных рационов</a>
<p class="home-card__content-description">Современный мир сложно представить без готовых кормов
для собак и кошек. И сложно поверить, что это относительно современная концепция,
существующая менее 150 лет. Поэтапно о том ...</p>
<div class="home-card__content-body">
<ul class="home-card__content-body__alerts">
<li>Обзоры</li>
<li>Тренды</li>
</ul>
<div class="home-card__content-body__day">21.10.24</div>
<div class="home-card__content-body__time">время чтения: 5 минут</div>
<div class="home-card__content-body__data">
<div>
<img src="{{ current_path }}/assets/img/heart.svg" alt="">
<span>22</span>
</div>
<div>
<img src="{{ current_path }}/assets/img/msg.svg" alt="">
<span>22</span>
</div>
<div>
<img src="{{ current_path }}/assets/img/user-logo.png" alt="" class="main-img">
</div>
</div>
<a href="#" class="home-card__content-body__link">читать статью</a>
</div>
</div>
</div>
</div>
<div class="swiper-slide">
<div class="home-card bg-violet">
<a href="#" class="home-card__img">
<img src="{{ current_path }}/assets/img/home-card-3.png" alt="">
</a>
<div class="home-card__content">
<a href="#" class="home-card__content-title">Пищевая аллергия у собак. Причины и пути
решения</a>
<p class="home-card__content-description">Даже привычный рацион может вызвать у питомца
нежелательную реакцию – зуд, расстройства ЖКТ, изменения в поведении. Хорошая новость: с
этой проблемой можно справиться. Рассказываем, как ...</p>
<div class="home-card__content-body">
<ul class="home-card__content-body__alerts">
<li>Обзоры</li>
<li>Тренды</li>
</ul>
<div class="home-card__content-body__day">21.10.24</div>
<div class="home-card__content-body__time">время чтения: 5 минут</div>
<div class="home-card__content-body__data">
<div>
<img src="{{ current_path }}/assets/img/heart.svg" alt="">
<span>22</span>
</div>
<div>
<img src="{{ current_path }}/assets/img/msg.svg" alt="">
<span>22</span>
</div>
<div>
<img src="{{ current_path }}/assets/img/user-logo.png" alt="" class="main-img">
</div>
</div>
<a href="#" class="home-card__content-body__link">читать статью</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% endfor %}
</div> </div>
</div> </div>
</div> </div>
{% endif %}

@ -1,2 +1,23 @@
<?php <?php
add_filter('timber/context', function($context) {
$current_category = get_queried_object(); // Получаем текущую категорию
$args = array(
'post_type' => 'post',
'posts_per_page' => 3, // Количество постов
'orderby' => 'meta_value_num',
'key' => 'post_views', // Поле плагина для подсчёта просмотров
'order' => 'DESC', // Сортировка по убыванию
// Условие для фильтрации по текущей категории
'category__in' => $current_category ? array($current_category->term_id) : '',
);
$most_read_query = new WP_Query($args);
$most_read = new Timber\PostQuery($most_read_query);
$context['most_read'] = $most_read;
return $context;
});

@ -0,0 +1,28 @@
<div class="anons-best">
<h2 class="anons-best__title">САМЫЕ ЧИТАЕМЫЕ:</h2>
<ul class="anons-best__card-wrap">
{% for post in most_read %}
<li class="anons-best__card">
<ul class="anons-best__card-alerts">
{% for category in post.categories %}
<li>
<a href="{{ category.link }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
<a href="{{post.link}}" class="main-img">
<img src="{{post.thumbnail.src}}" alt="{{post.thumbnail.alt}}">
</a>
<div class="anons-best__card-body">
<a href="{{post.link}}" class="anons-best__card-body__title">{{post.title}}</a>
<div class="anons-best__card-body__datas">
<p>{{post.date}}</p>
<p>время чтения: {{post.reading_time}}</p>
</div>
</div>
</li>
{% endfor %}
</ul>
</div>

@ -0,0 +1,21 @@
jQuery(document).ready(function ($) {
$('#ajax-load-blog').on('submit', function (e) {
e.preventDefault()
var data = $(this).serialize()
$.ajax({
url: '/wp-admin/admin-ajax.php', // Use the AJAX URL from wp_localize_script
type: 'POST',
data: data,
success: function (response) {
$(".anons-article__card-wrap").append(response)
$('#page_num').val(Number($('#page_num').val()) + 1)
if (Number($('#page_num').val()) >= Number($('#ajax-load-blog').data('total'))){
$('#ajax-load-blog').hide()
}
},
error: function (error) {
}
});
});
});

@ -0,0 +1,38 @@
<?php
include_module('blog');
function get_posts_by_page_and_category($paged = 1, $category = '') {
$args = [
'post_type' => 'post',
'posts_per_page' => 9, // Adjust the number of posts per page
'paged' => intval($paged) + 1,
];
if (!empty($category)) {
$args['tax_query'] = [
[
'taxonomy' => 'category',
'field' => 'slug', // or 'term_id', 'name' depending on how you identify categories
'terms' => $category,
],
];
}
$q = new WP_Query($args);
return new Timber\PostQuery($q);
}
function ajax_load_blog_posts() {
$page_num = isset($_POST['page_num']) ? sanitize_text_field($_POST['page_num']) : '';
$context = Timber::context();
$context['posts'] = get_posts_by_page_and_category($page_num);
$html = Timber::compile('/blog/components/news-list/component-template.twig', $context);
echo $html;
wp_die();
}
add_action('wp_ajax_load_blog_posts', 'ajax_load_blog_posts');
add_action('wp_ajax_nopriv_load_blog_posts', 'ajax_load_blog_posts');

@ -0,0 +1,22 @@
{% for post in posts %}
<li class="anons-best__card light">
<ul class="anons-best__card-alerts">
{% for category in post.categories %}
<li>
<a href="{{ category.link }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
<a href="{{post.link}}" class="main-img">
<img src="{{post.thumbnail.src}}" alt="{{post.thumbnail.alt}}">
</a>
<div class="anons-best__card-body">
<a href="{{post.link}}" class="anons-best__card-body__title">{{post.title}}</a>
<div class="anons-best__card-body__datas">
<p>{{post.date}}</p>
<p>время чтения: {{post.reading_time}}</p>
</div>
</div>
</li>
{% endfor %}

@ -0,0 +1,6 @@
<?php
$context = Timber::get_context();
Timber::render('blog/components/single/component-template.twig', $context);

@ -0,0 +1,49 @@
{% extends 'layout/module.template.twig' %}
{% block content %}
<!-- Breadcrumb -->
<section class="breadcrumb">
<div class="container">
<a href="{{ site.url }}">Главная</a> /
<a href="{{ site.url }}">Блог</a> /
<a href="{{ post.link }}">{{ post.name }}</a>
</div>
</section>
<!-- Breadcrumb end -->
<!-- Article home -->
<section class="article-home">
<div class="container">
<h1>{{post.name}}</h1>
<div class="article-home__data">
<ul class="article-home__data-alerts">
{% for category in post.categories %}
<li>
<a href="{{ category.link }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
<p>{{post.date}}</p>
<p>время чтения: {{post.reading_time}}</p>
</div>
<div class="article-home__card">
<img src="{{post.thumbnail.src}}" alt="{{post.thumbnail.alt}}">
</div>
</div>
</section>
<!-- Article home end -->
<!-- Article content -->
<div class="article-content">
<div class="article-container">
{{post.content}}
</div>
<!-- Article content end -->
{% endblock %}

@ -1,2 +1,21 @@
<?php <?php
add_filter('timber/context', function($context) {
$categories = get_categories();
$current_category = get_queried_object();
if (isset($current_category) && !is_wp_error($current_category) && !empty($current_category->name)) {
$category_name = $current_category->name;
} else {
$category_name = null;
}
$context['category_list'] = $categories;
$context['current_category'] = $category_name;
return $context;
});

@ -0,0 +1,15 @@
<div class="anons-theme">
<h3 class="anons-theme__title">Темы:</h3>
<ul>
<li>
<a href="" class="{% if not current_category %} active {% endif %}">ВСЕ</a>
</li>
{% for category in category_list %}
<li>
<a href="{{ category.link }}" class="{% if current_category == category.name %} active {% endif %}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
</div>

@ -0,0 +1,139 @@
.texts {
display: flex;
flex-direction: column;
gap: 48px;
}
.texts h2 {
font-size: 36px;
line-height: 40px;
font-weight: bold;
color: var(--grey-black);
text-transform: uppercase;
}
.texts h3 {
font-size: 24px;
line-height: 28px;
font-weight: bold;
color: var(--grey-black);
text-transform: uppercase;
}
.texts-description {
display: flex;
flex-direction: column;
gap: 48px;
}
.texts-description p {
color: var(--grey-black);
font-size: 24px;
line-height: 32px;
font-weight: 500;
}
.texts-description a {
display: inline;
text-decoration: underline;
}
.texts ol {
display: flex;
flex-direction: column;
gap: 12px;
font-size: 24px;
line-height: 32px;
font-weight: 500;
color: #191919;
}
.texts ol li {
display: flex;
align-items: center;
gap: 12px;
}
.texts ol h4 {
background: var(--accent-1);
border-radius: 5.2px;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
line-height: 32px;
font-weight: 500;
color: white;
}
.texts ul {
display: flex;
flex-direction: column;
gap: 12px;
}
.texts ul li {
padding-left: 22px;
font-size: 24px;
font-weight: 500;
line-height: 32px;
color: #191919;
position: relative;
}
.texts ul li::before {
content: "";
width: 10px;
height: 10px;
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
background: var(--accent-1);
border-radius: 3px;
}
@media only screen and (max-width: 992px) {
.texts h2 {
font-size: 28px;
line-height: 32px;
}
.texts h3 {
font-size: 20px;
line-height: 24px;
}
.texts-description p {
font-size: 18px;
line-height: 24px;
}
.texts ol {
gap: 12px;
}
.texts ol li {
font-size: 18px;
line-height: 24px;
}
.texts ol li h4 {
font-size: 18px;
line-height: 24px;
}
.texts ul {
gap: 12px;
}
.texts ul li {
font-size: 18px;
line-height: 24px;
}
}

@ -0,0 +1,37 @@
<?php
function texts_render_callback($block, $content = '', $is_preview = false, $post_id = 0) {
$context = Timber::context();
$context['block'] = $block;
$context['is_preview'] = $is_preview;
$context['content'] = get_field('content');
Timber::render('modules/blog/editor-blocks/texts/editor-block-template.twig', $context);
}
add_action('acf/init', function(){
if( function_exists('acf_register_block') ) {
// register a testimonial block
acf_register_block(array(
'name' => 'gp_texts',
'title' => __('GP - Texts'),
'description' => __('A block to serve a text content'),
'render_callback' => 'texts_render_callback',
'category' => 'formatting',
'icon' => 'admin-comments',
'keywords' => array( 'texts', 'simple block', 'gp-block',),
'mode' => 'preview',
'enqueue_assets' => function(){
wp_enqueue_style('gp_util_style', get_template_directory_uri() . '/modules/layout/assets/css/gp-style-core.css', array(), '1.0', 'all');
wp_enqueue_style('gp_normalize', get_template_directory_uri() . '/modules/layout/assets/css/gp-style-normalize.css', array(), '1.0', 'all');
wp_enqueue_style('gp_texts_style', get_template_directory_uri() . '/modules/blog/editor-blocks/texts/assets/css/style.css', array(), '1.0', 'all');
}
));
}
});
?>

@ -0,0 +1,33 @@
<?php
class BlogPost extends \Timber\Post
{
/**
* Estimates time required to read a post.
*
* The words per minute are based on the English language, which e.g. is much
* faster than German or French.
*
* @link https://www.irisreading.com/average-reading-speed-in-various-languages/
*
* @return string
*/
public function reading_time()
{
$symb_per_minute = 2280;
$symb = strlen(wp_strip_all_tags($this->content()));
$minutes = round($symb / $symb_per_minute);
/* translators: %s: Time duration in minute or minutes. */
return sprintf(_n('%s мин.', '%s мин.', $minutes), (int) $minutes);
}
}
add_filter('timber/post/classmap', function ($classmap) {
$custom_classmap = [
'post' => BlogPost::class,
];
return array_merge($classmap, $custom_classmap);
});

@ -0,0 +1,87 @@
/* Header */
.header {
background: var(--main_white);
border-bottom: 1px solid var(--interface_title);
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 4;
}
.header-container {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 0;
}
.header-bars {
display: none;
}
.header-logo {
display: flex;
align-items: center;
gap: 8px;
}
.header-logo span {
color: var(---main_black);
font-size: 20px;
text-transform: uppercase;
}
.header-navs {
display: flex;
align-items: center;
gap: 24px;
}
.header-navs__link {
padding: 8px 12px;
font-size: 16px;
font-weight: bold;
text-transform: uppercase;
line-height: 20px;
}
.header-accordion {}
.header-accordion__btn {
display: flex;
align-items: center;
gap: 4px;
padding: 8px 12px;
border-radius: 24px;
background: var(--accent-2);
cursor: pointer;
user-select: none;
font-size: 16px;
font-weight: bold;
line-height: 20px;
color: var(---main_black);
}
.header-right {
display: flex;
align-items: center;
gap: 8px;
}
.header-lang__btn {
display: flex;
align-items: center;
cursor: pointer;
user-select: none;
gap: 4px;
padding: 12px 15px;
color: var(---main_black);
font-size: 16px;
font-weight: bold;
line-height: 20px;
}
/* Header end */

@ -0,0 +1,32 @@
/* Стили для планшетов */
@media only screen and (max-width: 992px) {
.header-navs {
display: none;
}
.header-container {
height: 56px;
padding: 0;
}
.header-bars {
display: flex;
align-items: center;
justify-content: center;
}
.header-logo {
font-size: 16px;
line-height: 20px;
gap: 8px;
}
.header-logo img {
width: 31px;
flex-shrink: 0;
}
.header-lang {
display: none;
}
}

@ -0,0 +1,4 @@
/* Стили для ультрашироких экранов */
@media only screen and (min-width: 1400px) {
}

@ -0,0 +1,11 @@
@media (max-width: 1200px) {
.header-navs {
gap: 12px;
}
.header-navs__link {
font-size: 14px;
}
.header-right {
gap: 4px;
}
}

@ -0,0 +1,4 @@
<!-- Подключаем хуки ajax_wp стандартным способом
данный файл подключается только при ajax запросах на сервер
поэтому не нужно использовать его для хранени
функций используемых вне ajax логики -->

@ -0,0 +1,12 @@
<?php
add_filter('timber/context', function($context) {
#Подготавливаем данные для рендеринга
#$context['field_name'] = get_field('field_name')
return $context;
});
$context = Timber::get_context();
# Если необходимо рендерим шаблон компонента
#Timber::render('example/components/example/component-template.twig', $context);

@ -0,0 +1,33 @@
{% extends 'layout/module.template.twig' %}
{% block content %}
<!-- Home -->
<section class="home">
<div class="container">
<h1 class="home-title">БЛОГ</h1>
<p class="home-description">Мы пишем про то, что нас по‑настоящему цепляет: биотехнологии, науку, здоровье и то, как этот мир сделать лучше. Мы не боимся сложных тем и неудобных вопросов, ведь именно с них начинается будущее</p>
{% include '/blog/components/featured-slider/component-template.twig' %}
</div>
</section>
<!-- Home end -->
<!-- Anons -->
<section class="anons">
<div class="container">
{% include '/blog/components/themes/component-template.twig' %}
{% include '/blog/components/most-read/component-template.twig' %}
{% include '/blog/components/news-list/component-template.twig' %}
</section>
<!-- Anons end -->
<!-- Author -->
{% include '/blog/components/author-banner/component-template.twig' %}
<!-- Author end -->
<!-- Editorial -->
{% include '/blog/components/editorial/component-template.twig' %}
<!-- Editorial end -->
{% endblock %}

@ -29,7 +29,6 @@
</main> </main>
{% include 'footer/module.template.twig' %} {% include 'footer/module.template.twig' %}
</div> </div>
{{ function('wp_footer') }} {{ function('wp_footer') }}
</body> </body>

@ -0,0 +1,6 @@
<?php
include_module('blog');
include_component('blog', 'single');
?>
Loading…
Cancel
Save