[][src]Function ghost2zola::extract_archive

pub fn extract_archive<AP, EP>(
    archive_path: AP,
    prefix: Option<PathBuf>,
    extract_path: EP
) -> Result<usize, Error> where
    AP: AsRef<Path>,
    EP: AsRef<Path>, 

Extract an archive into a destination folder.

Image Handling

Assuming that the ghost DB is located in a/b/c/data/ghost.db, in a standard configuration, the images will be located in a/b/c/images/yyyy/mm/*. They will be extracted into extract_path/yyyy/mm/*.

Post Handling

Posts are extracted from the Ghost-format sqlite DB and converted into Zola-compatible format.

WARN: if the post's original markdown has been lost, i.e. from a previous Ghost import, it will be skipped! In that circumstance, consider regenerating the markdown from the rendered post content within the database with a different tool.

Each post will be extracted into extract_path/yyyy/mm/dd/slug.

Self-hosted images

Within each post's markdown, things which look like image links, i.e. things which match the regex \]\(/content/images/\d{4}/\d{2}/[^)]+\), will have the /content/images portion stripped out and replaced with /blog, ending up as ](/blog/dddd/mm/$1). This should preserve the links.

Metadata

Zola expects post metadata to exist in TOML front matter prepended to each post. The following metadata is extracted from the DB and rendered into the frontmatter:

Ghost Sql FieldZola Frontmatter KeyNotes
titletitle
meta_descriptiondescriptionnot set if empty
published_atdatenot set if empty
updated_atupdatednot set if empty
statusdraft"published" => false; anything else => true; not set if false
slugslug
languageextra.language
users.nameextra.author_nameposts inner join users on posts.author_id = users.id
tags.nametaxonomies.tagsselect tags.name from posts_tags inner join tags on posts_tags.tag_id = tags.id where posts_tags.post_id = %