/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 * 
 * Modified by David Garcia for Finboot.
 *
 * Modfications: 
 * - Remove truncated post support.
 * - Custom style.
 */

// @ts-ignore the api exists on the package but is not exposed
import { useBlogPost } from '@docusaurus/theme-common/internal';
import EditThisPage from '@theme/EditThisPage';
import TagsListInline from '@theme/TagsListInline';
import clsx from 'clsx';
import React from 'react';

import styles from './styles.module.css';

export default function BlogPostItemFooter(): JSX.Element | null {
  const {metadata, isBlogPostPage} = useBlogPost();
  const {tags, editUrl} = metadata;


  const tagsExists = tags.length > 0;

  const renderFooter = tagsExists || editUrl;

  if (!renderFooter) {
    return null;
  }

  return (
    <footer
      className={clsx(
        'row', styles.postFooter,
        isBlogPostPage && styles.blogPostFooterDetailsFull,
      )}>
      {!isBlogPostPage && tagsExists && (
        <div>
          <TagsListInline tags={tags} />
        </div>
      )}

      {isBlogPostPage && editUrl && (
        <div>
          <EditThisPage editUrl={editUrl} />
        </div>
      )}
    </footer>
  );
}
