HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //var/www/quadcode.com/src/utils/postNormalizer.ts
import type { IPost } from '$type/post';

export const normalizePost = (post: Partial<IPost>): IPost => {
  return {
    id: post.id ?? 0,
    aiSummary: post.aiSummary ?? '',
    imageData: {
      thumbnail: post.imageData?.thumbnail ?? '',
      medium: post.imageData?.medium ?? '',
      mediumLarge: post.imageData?.mediumLarge ?? '',
      large: post.imageData?.large ?? '',
    },
    date: post.date ?? '',
    date_gmt: post.date_gmt ?? '',
    guid: {
      rendered: post.guid?.rendered ?? '',
    },
    modified: post.modified ?? '',
    modified_gmt: post.modified_gmt ?? '',
    slug: post.slug ?? '',
    status: post.status ?? '',
    type: post.type ?? '',
    link: post.link ?? '',
    title: {
      rendered: post.title?.rendered ?? '',
    },
    content: {
      rendered: post.content?.rendered ?? '',
      protected: post.content?.protected ?? false,
    },
    excerpt: {
      rendered: post.excerpt?.rendered ?? '',
      protected: post.excerpt?.protected ?? false,
    },
    expertData: post.expertData ?? null,
    author: post.author ?? 0,
    authorData: {
      name: post.authorData?.name ?? '',
      description: post.authorData?.description ?? '',
      position: post.authorData?.position ?? '',
      slug: post.authorData?.slug ?? '',
      totalPosts: post.authorData?.totalPosts ?? 0,
      avatar: {
        thumbnail: post.authorData?.avatar?.thumbnail ?? '',
        medium: post.authorData?.avatar?.medium ?? '',
        mediumLarge: post.authorData?.avatar?.mediumLarge ?? '',
        large: post.authorData?.avatar?.large ?? '',
      },
      linkedin: post.authorData?.linkedin ?? '',
    },
    featured_media: post.featured_media ?? 0,
    comment_status: post.comment_status ?? '',
    ping_status: post.ping_status ?? '',
    sticky: post.sticky ?? false,
    template: post.template ?? '',
    format: post.format ?? '',
    meta: {
      footnotes: post.meta?.footnotes ?? '',
    },
    categories: post.categories ?? [],
    tags: post.tags ?? [],
    tagsData: post.tagsData ?? [],
    views: post.views ?? '',
    acf: {
      views: post.acf?.views ?? '',
      faq: post.acf?.faq ?? [],
    },
    readAlso: post.readAlso ?? [],
    estReadingTime: post.estReadingTime ?? '',
    yoast_head: post.yoast_head ?? '',
    yoast_head_json: {
      title: post.yoast_head_json?.title ?? '',
      robots: {
        index: post.yoast_head_json?.robots?.index ?? '',
        follow: post.yoast_head_json?.robots?.follow ?? '',
        'max-snippet': post.yoast_head_json?.robots?.['max-snippet'] ?? '',
        'max-image-preview': post.yoast_head_json?.robots?.['max-image-preview'] ?? '',
        'max-video-preview': post.yoast_head_json?.robots?.['max-video-preview'] ?? '',
      },
      og_locale: post.yoast_head_json?.og_locale ?? '',
      og_type: post.yoast_head_json?.og_type ?? '',
      og_title: post.yoast_head_json?.og_title ?? '',
      og_description: post.yoast_head_json?.og_description ?? '',
      og_url: post.yoast_head_json?.og_url ?? '',
      og_site_name: post.yoast_head_json?.og_site_name ?? '',
      article_published_time: post.yoast_head_json?.article_published_time ?? '',
      article_modified_time: post.yoast_head_json?.article_modified_time ?? '',
      og_image: post.yoast_head_json?.og_image ?? [
        {
          width: 0,
          height: 0,
          url: '',
          type: '',
        },
      ],
      author: post.yoast_head_json?.author ?? '',
      twitter_card: post.yoast_head_json?.twitter_card ?? '',
      twitter_misc: {
        'Written by': post.yoast_head_json?.twitter_misc?.['Written by'] ?? '',
        'Est. reading time': post.yoast_head_json?.twitter_misc?.['Est. reading time'] ?? '',
      },
    },
  };
};