-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpelicanconf.py
115 lines (86 loc) · 2.6 KB
/
pelicanconf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import os.path
import time
import pathlib
import datetime
import markdown_ext
env_name = os.getenv("ENV")
IS_DEV = env_name == "dev"
IS_PDF = env_name == "pdf"
AUTHOR = "Shrikant Sharat Kandula"
SITENAME = "The Sharat's"
PROD_SITEURL = "https://sharats.me"
SITEURL = "" if IS_DEV else PROD_SITEURL
THEME = "theme"
PATH = "content"
_root_static = "root-static"
STATIC_PATHS = ["static", _root_static]
EXTRA_PATH_METADATA = {
str(p.relative_to(PATH)): { "path": str(p.relative_to(os.path.join(PATH, _root_static))) }
for p in pathlib.Path(PATH, _root_static).glob("**/*")
}
FILENAME_METADATA = r"(?:(?P<date>\d{4}-\d{2}-\d{2})-)?(?P<slug>[-a-z0-9]*)"
MARKDOWN = {
# Extensions at <https://python-markdown.github.io/extensions/>.
"extension_configs": {
"markdown.extensions.codehilite": {
# Pygments formatter options from <https://pygments.org/docs/formatters/#HtmlFormatter>.
"pygments_formatter": markdown_ext.CustomFormatter,
"guess_lang": False,
"cssclass": "hl",
},
"markdown.extensions.extra": {},
"markdown.extensions.meta": {},
"markdown.extensions.toc": {
"title": "Table of Contents",
"marker": "[TOC]",
"permalink": True,
},
"markdown.extensions.sane_lists": {},
"markdown.extensions.smarty": {},
"markdown_ext": {},
},
"output_format": "html5",
}
TIMEZONE = "Asia/Kolkata"
FEED_DOMAIN = PROD_SITEURL
FEED_ALL_ATOM = "posts/index.xml"
DELETE_OUTPUT_DIRECTORY = True
# Content with dates in the future should get a default status of `draft`.
WITH_FUTURE_DATES = False
# Order is hard to get if pages were to show automatically in the menu. So we specify explicitly.
MENUITEMS = [
("Posts", "/posts/"),
("Labs", "/labs/"),
# ("Rèsumè", "/resume/"),
]
DEFAULT_PAGINATION = False
RELATIVE_URLS = False
ARTICLE_URL = "posts/{slug}/"
ARTICLE_SAVE_AS = "posts/{slug}/index.html"
PAGE_URL = "{slug}/"
PAGE_SAVE_AS = "{slug}/index.html"
ARCHIVES_URL = "posts/"
ARCHIVES_SAVE_AS = "posts/index.html"
TAG_URL = "tags/{slug}/"
TAG_SAVE_AS = "tags/{slug}/index.html"
DATE_FORMATS = {
"en": "%-d %b %Y",
}
def _render_markdown(text: str):
from markdown import markdown
return markdown(text).strip()[len("<p>"):-len("</p>")]
JINJA_FILTERS = {
"markdown": _render_markdown,
}
JINJA_GLOBALS = {
"date_iso": datetime.date.today().isoformat(),
"current_year": time.strftime("%Y"),
}
PLUGINS = [
"pelican_ext",
"sitemap", # Generates a sitemap XML.
]
SITEMAP = {
"format": "xml",
"exclude": ["drafts/"],
}