from pathlib import Path
import shutil


def prepare_workdir(workdir: Path):
    """Create necessary directories if needed, such as templates directiry, articles directory, etc.

    :param workdir: Working directory, where the blog is generated.
    :return: Working dir and Template dir Path objects
    """
    workdir.joinpath('articles').mkdir(exist_ok=True)

    templates_dir = workdir / 'templates'
    if not templates_dir.exists():
        app_templates_dir = Path(__file__).parent / 'templates'

        # Move the default template dir to the current workdir
        shutil.copytree(app_templates_dir, templates_dir)

    return workdir, templates_dir