import toml


def load_zola_md(filepath):
    """
    Loads a zola markdown file and returns its metadata (as dict) and 
    content as string
    """

    meta = {}
    text = {}

    with open(filepath) as f:
        md = f.read()

    split = md.split("+++")
    if len(split) != 3:
        print("invalid zola markdown file")
        raise IOError
    text = split[-1]
    meta = toml.loads(split[1])

    return meta, text