feat: complete scheduled publishing, security remediation and DEV_TICKETS implementation
This commit is contained in:
1 parent
d6d4158cbe
commit
efb3c473c4
35 files changed
+685
-185
No files matched your search
@@ -39,19 +39,23 @@ export default function AnalyticsDeferred({ gtmId, gaId, clarityId }: AnalyticsD
|
||||
document.head.appendChild(gtmScript);
|
||||
}
|
||||
|
||||
// 2. Google Analytics 4 (if standalone without GTM)
|
||||
if (gaId && !gtmId) {
|
||||
// 2. Google Analytics 4 (ensures GA4 hits fire directly even if GTM container lacks GA4 config tag)
|
||||
if (gaId) {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(...args: any[]) {
|
||||
window.dataLayer?.push(args);
|
||||
}
|
||||
(window as any).gtag = gtag;
|
||||
gtag('js', new Date());
|
||||
gtag('config', gaId, { page_path: window.location.pathname });
|
||||
|
||||
const gaScript = document.createElement('script');
|
||||
gaScript.async = true;
|
||||
gaScript.src = `https://www.googletagmanager.com/gtag/js?id=${gaId}`;
|
||||
document.head.appendChild(gaScript);
|
||||
// Only append gtag.js script if not already added
|
||||
if (!document.querySelector(`script[src*="${gaId}"]`)) {
|
||||
const gaScript = document.createElement('script');
|
||||
gaScript.async = true;
|
||||
gaScript.src = `https://www.googletagmanager.com/gtag/js?id=${gaId}`;
|
||||
document.head.appendChild(gaScript);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Microsoft Clarity
|
||||
|
||||
@@ -52,16 +52,24 @@ export interface BlogPostItem {
|
||||
export default function BlogPage({
|
||||
blogs = [],
|
||||
categories = [],
|
||||
initialCategoryId = 'ALL',
|
||||
}: {
|
||||
blogs: BlogPostItem[];
|
||||
categories?: BlogCategory[];
|
||||
initialCategoryId?: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>("ALL");
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>(initialCategoryId);
|
||||
const [searchQuery, setSearchQuery] = useState<string>("");
|
||||
const [selectedTag, setSelectedTag] = useState<string | null>(null);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (initialCategoryId) {
|
||||
setSelectedCategory(initialCategoryId);
|
||||
}
|
||||
}, [initialCategoryId]);
|
||||
|
||||
React.useEffect(() => {
|
||||
productService.getProducts({ limit: 8 }).then((res) => setProducts(res.data));
|
||||
}, []);
|
||||
@@ -184,7 +192,10 @@ export default function BlogPage({
|
||||
{/* Category Filter Pills */}
|
||||
<div className="flex items-center gap-2 overflow-x-auto pb-1 scrollbar-none">
|
||||
<button
|
||||
onClick={() => setSelectedCategory("ALL")}
|
||||
onClick={() => {
|
||||
setSelectedCategory("ALL");
|
||||
router.replace('/blog', { scroll: false });
|
||||
}}
|
||||
className={`px-4 py-2 rounded-2xl text-xs font-black transition-all cursor-pointer whitespace-nowrap ${
|
||||
selectedCategory === "ALL"
|
||||
? "bg-canina-blue text-white shadow-md shadow-canina-blue/20 scale-102"
|
||||
@@ -196,7 +207,10 @@ export default function BlogPage({
|
||||
{categories.map((c) => (
|
||||
<button
|
||||
key={c.id}
|
||||
onClick={() => setSelectedCategory(c.id)}
|
||||
onClick={() => {
|
||||
setSelectedCategory(c.id);
|
||||
router.replace(`/blog?categoryId=${c.id}`, { scroll: false });
|
||||
}}
|
||||
className={`px-4 py-2 rounded-2xl text-xs font-black transition-all cursor-pointer whitespace-nowrap ${
|
||||
selectedCategory === c.id
|
||||
? "bg-canina-blue text-white shadow-md shadow-canina-blue/20 scale-102"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
"use client";
|
||||
import Link from "next/link";
|
||||
import { useState, useMemo, useEffect, useRef } from "react";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import {
|
||||
@@ -1021,7 +1022,12 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
<h4 className="text-[11px] font-black text-medical-gray-400 uppercase tracking-wider font-vazir">مواد تشکیلدهنده برتر</h4>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{product.main_ingredients.map((ing, idx) => {
|
||||
const termKey = termKeys.find(key => {
|
||||
const matchedItem = product.ingredientItems?.find(
|
||||
item => item.ingredient.trim().toLowerCase() === ing.trim().toLowerCase()
|
||||
);
|
||||
const cardSlug = matchedItem?.ingredientCardSlug;
|
||||
|
||||
const termKey = !cardSlug ? termKeys.find(key => {
|
||||
const termObj = scientificTerms[key] || SCIENTIFIC_TERMS[key];
|
||||
const termName = termObj?.term || key;
|
||||
const ingClean = ing.toLowerCase();
|
||||
@@ -1031,15 +1037,27 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
keyClean.includes(ingClean) ||
|
||||
ingClean.includes(termNameClean) ||
|
||||
termNameClean.includes(ingClean);
|
||||
});
|
||||
}) : null;
|
||||
|
||||
return (
|
||||
<div key={idx} className="bg-medical-gray-50 border border-medical-gray-200 px-3 py-1.5 rounded-xl flex items-center gap-1.5 group hover:border-canina-blue/30 hover:bg-canina-blue/5 transition-all">
|
||||
<span className="text-xs sm:text-sm font-bold text-medical-gray-700 font-vazir">
|
||||
{termKey ? (
|
||||
{cardSlug ? (
|
||||
<Link
|
||||
href={`/wiki/${cardSlug}`}
|
||||
className="hover:text-canina-blue hover:underline transition-colors flex items-center gap-1"
|
||||
title="مشاهده در دانشنامه علمی کنینا"
|
||||
>
|
||||
<span>{ing}</span>
|
||||
<span className="text-[10px] text-canina-blue bg-canina-blue/10 px-1.5 py-0.5 rounded-md font-normal">دانشنامه</span>
|
||||
</Link>
|
||||
) : termKey ? (
|
||||
<Tooltip termKey={termKey} onWikiNavigate={(id) => router.push(`/wiki?term=${id}`)}>
|
||||
{ing}
|
||||
</Tooltip>
|
||||
) : ing}
|
||||
) : (
|
||||
ing
|
||||
)}
|
||||
</span>
|
||||
<Sparkles className="w-3 h-3 text-canina-blue opacity-40 group-hover:opacity-100 transition-opacity" />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user