[−][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 Field | Zola Frontmatter Key | Notes |
---|---|---|
title | title | |
meta_description | description | not set if empty |
published_at | date | not set if empty |
updated_at | updated | not set if empty |
status | draft | "published" => false ; anything else => true ; not set if false |
slug | slug | |
language | extra.language | |
users.name | extra.author_name | posts inner join users on posts.author_id = users.id |
tags.name | taxonomies.tags | select tags.name from posts_tags inner join tags on posts_tags.tag_id = tags.id where posts_tags.post_id = % |