import { useParams } from 'react-router-dom';

export const useArticleId = () => {
  const params = useParams();

  const rootId = params.rootId ? parseInt(params.rootId) : undefined;
  const childId = params.childId ? parseInt(params.childId) : undefined;
  const articleId = childId ?? rootId;

  return { rootId, childId, articleId };
};
