export to bundles of articles/index.md
This commit is contained in:
parent
b6097f336e
commit
c62c516541
@ -37,17 +37,22 @@ if len(sys.argv) > 1:
|
|||||||
fetch = cursor.fetchall()
|
fetch = cursor.fetchall()
|
||||||
else:
|
else:
|
||||||
fetch = cursor.fetchmany(3)
|
fetch = cursor.fetchmany(3)
|
||||||
print("--- {} articles will be converted to Markdown files wihth YAML metadata ---\n".format(len(fetch)))
|
|
||||||
|
print("--- Conversion of {} articles to Markdown files + YAML metadata ---\n"
|
||||||
|
.format(len(fetch)))
|
||||||
|
|
||||||
|
if len(fetch) < 5:
|
||||||
pprint(fetch)
|
pprint(fetch)
|
||||||
|
|
||||||
# Loop among every articles & export them in Markdown files
|
# Loop among every articles & export them in Markdown files
|
||||||
for row in fetch:
|
for row in fetch:
|
||||||
meta = metadata(row)
|
meta = metadata(row)
|
||||||
body = content(row[7])
|
body = content(row[7])
|
||||||
with open("{}/{}.{}".format(outputDir, meta.get_slug(), outputType), "w") as f:
|
articleDir = "{}/{}".format(outputDir, meta.get_slug())
|
||||||
f.write("{}\n{}\n{}".format(
|
os.mkdir(articleDir)
|
||||||
meta.get_frontmatter(), meta.get_title(), body.get_markdown())
|
with open("{}/index.md".format(articleDir), "w") as f:
|
||||||
)
|
f.write("{}\n{}\n{}"
|
||||||
|
.format(meta.get_frontmatter(), meta.get_title(), body.get_markdown()))
|
||||||
|
|
||||||
# Close the database connection
|
# Close the database connection
|
||||||
db.close()
|
db.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user