~scolby33/scolbyblog

ref: 89059ec82fc6aab3f6899f1e716c4da238545dfa scolbyblog/pelicanconf.py -rw-r--r-- 5.9 KiB
89059ec8Scott Colby Forgot the second test command. 9 months ago
                                                                                
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals

import datetime
from pathlib import Path
from textwrap import dedent
from urllib.parse import urljoin
import xml.etree.ElementTree as etree

ordinal = lambda n: "%d%s" % (
    n,
    "tsnrhtdd"[(n // 10 % 10 != 1) * (n % 10 < 4) * n % 10 :: 4],
)


def fromisoformat(value: str) -> datetime.datetime:
    """Convert an ISO format string to a datetime."""
    return datetime.datetime.fromisoformat(value)


def isoformat(value: datetime.datetime) -> datetime.datetime:
    """Convert a datetime to an ISO-formatted string."""
    return value.isoformat()


def fancydate(value: datetime.datetime) -> str:
    """Translate a datetime to a string like 'Wednesday the 1st of January, 2020'."""
    dayname = value.strftime("%A")
    day = int(value.strftime("%d"))
    monthyear = value.strftime("%B, %Y")
    return f"{dayname} the {ordinal(day)} of {monthyear}"


# Base url
SITEURL = ""

# Themes
THEME = "themes/scolbyblog"
THEME_STATIC_DIR = "assets"

# Scolbyblog theme settings
AVATAR = "images/me.4905fada.jpg"
INTRODUCTION = dedent(
    """\
    <p>
        My name is Scott Colby.
        I am a software developer and chemist.
        I work in Python and Rust, and deploy with Kubernetes, Ansible, and bare Linux machines.
    </p>
    <p>
        I use this site to post interesting things that I've worked on and as a personal notebook to document things that I've figured out so I won't forget them.
    </p>
    """
)
MENUITEMS = [
    ("RSS", f"{SITEURL}/feeds/atom.xml"),
    ("GitHub", "https://www.github.com/scolby33"),
    ("LinkedIn", "https://www.linkedin.com/in/scott-colby-902606a8"),
]


# Basic settings
USE_FOLDER_AS_CATEGORY = False
DISPLAY_CATEGORIES_ON_MENU = False
JINJA_FILTERS = {
    "fromisoformat": fromisoformat,
    "isoformat": isoformat,
    "fancydate": fancydate,
}
link_img = etree.Element("img")
link_img.attrib["src"] = f"/{THEME_STATIC_DIR}/link.svg"
link_img.attrib["alt"] = "link icon"
MARKDOWN = {
    "extension_configs": {
        "markdown.extensions.codehilite": {
            "css_class": "highlight",
            "guess_lang": False,
        },
        "markdown.extensions.extra": {},
        "markdown.extensions.meta": {},
        "markdown.extensions.sane_lists": {},
        "markdown.extensions.toc": {
            "permalink": link_img,
            "permalink_class": "deeplink",
            "permalink_title": False,
            "permalink_attribs": {"aria-label": "Anchor"},
        },
    },
    "output_format": "html5",
}
PATH = "content"
SITENAME = "Scott Colby"
STATIC_PATHS = ["images", "favicons"]
EXTRA_PATH_METADATA = {
    str(p.relative_to(PATH)): {"path": p.name}
    for p in (Path(PATH) / "favicons").glob("*")
}
TYPOGRIFY = True

# Plugins and their Config
PLUGIN_PATHS = ["plugins"]
PLUGINS = ["pelican_webassets", "og_image_generator", "feed_interceptor", "sitemap"]
WEBASSETS_CONFIG = [("AUTOPREFIXER_BIN", "autoprefixer-cli")]
MINIFY = {
    "remove_comments": True,
    "remove_empty_space": True,
    "reduce_boolean_attributes": True,
    "remove_optional_attribute_quotes": True,
    "convert_charrefs": True,
}
OG_FOREGROUND_COLOR = "#061e27"
OG_BACKGROUND_COLOR = "#afdef1"
# remove deeplink anchors from generated feeds, where they're not necessary
FEED_INTERCEPTOR_FILTERS = [
    (("a",), {"class_": "deeplink"}),
]
SITEMAP = {
    "format": "xml",
    "changefreqs": {"articles": "weekly", "pages": "weekly", "indexes": "daily"},
}

# URL settings
INDEX_NAME = "index.html"

RELATIVE_URLS = False

article_base = "{date:%Y}/{date:%m}/{date:%d}/"
ARTICLE_URL = urljoin(article_base, "{slug}/")
ARTICLE_SAVE_AS = urljoin(ARTICLE_URL, INDEX_NAME)
ARTICLE_LANG_URL = urljoin(article_base, "{slug}-{lang}/")
ARTICLE_LANG_SAVE_AS = urljoin(ARTICLE_LANG_URL, INDEX_NAME)

draft_base = "draft/"
DRAFT_URL = urljoin(draft_base, "{slug}/")
# DRAFT_SAVE_AS = urljoin(DRAFT_URL, INDEX_NAME)
DRAFT_SAVE_AS = ""
DRAFT_LANG_URL = urljoin(draft_base, "{slug}-{lang}/")
# DRAFT_LANG_SAVE_AS = urljoin(DRAFT_LANG_URL, INDEX_NAME)
DRAFT_LANG_SAVE_AS = ""

page_base = ""
PAGE_URL = urljoin(page_base, "{slug}/")
PAGE_SAVE_AS = urljoin(PAGE_URL, INDEX_NAME)
PAGE_LANG_URL = urljoin(page_base, "{slug}-{lang}/")
PAGE_LANG_SAVE_AS = urljoin(PAGE_LANG_URL, INDEX_NAME)

draft_page_base = "draft/page/"
DRAFT_PAGE_URL = urljoin(draft_page_base, "{slug}/")
# DRAFT_PAGE_SAVE_AS = urljoin(DRAFT_PAGE_URL, INDEX_NAME)
DRAFT_PAGE_SAVE_AS = ""
DRAFT_PAGE_LANG_URL = urljoin(draft_page_base, "{slug}-{lang}/")
# DRAFT_PAGE_LANG_SAVE_AS = urljoin(DRAFT_PAGE_LANG_URL, INDEX_NAME)
DRAFT_PAGE_LANG_SAVE_AS = ""

AUTHOR_URL = "author/{slug}/"
# AUTHOR_SAVE_AS = urljoin(AUTHOR_URL, INDEX_NAME)
AUTHOR_SAVE_AS = ""

CATEGORY_URL = "category/{slug}/"
# CATEGORY_SAVE_AS = urljoin(CATEGORY_URL, INDEX_NAME)
CATEGORY_SAVE_AS = ""

TAG_URL = "tag/{slug}/"
# TAG_SAVE_AS = urljoin(TAG_URL, INDEX_NAME)
TAG_SAVE_AS = ""

ARCHIVES_URL = "archives/"
# ARCHIVES_SAVE_AS = urljoin(ARCHIVES_URL, INDEX_NAME)
ARCHIVES_SAVE_AS = ""

AUTHORS_URL = "author/"
# AUTHORS_SAVE_AS = urljoin(AUTHORS_URL, INDEX_NAME)
AUTHORS_SAVE_AS = ""

CATEGORIES_URL = "category/"
# CATEGORIES_SAVE_AS = urljoin(CATEGORY_URL, INDEX_NAME)
CATEGORIES_SAVE_AS = ""

TAGS_URL = "tag/"
# TAGS_SAVE_AS = urljoin(TAGS_URL, INDEX_NAME)
TAGS_SAVE_AS = ""

INDEX_SAVE_AS = INDEX_NAME

# Time and Date
TIMEZONE = "Etc/UTC"
DEFAULT_DATE = "fs"
LOCALE = "en_US.UTF-8"

# Template pages
DIRECT_TEMPLATES = ["index"]

# Metadata
AUTHOR = "Scott Colby"

# Feed settings
FEED_DOMAIN = "https://www.scolby.com"
FEED_ATOM = "feeds/atom.xml"
# FEED_RSS = "feeds/rss.xml"
FEED_RSS = None
FEED_ALL_ATOM = None
FEED_ALL_RSS = None
CATEGORY_FEED_ATOM = None
CATEGORY_FEED_RSS = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
TAG_FEED_ATOM = None
TAG_FEED_RSS = None
TRANSLATION_FEED_ATOM = None
TRANSLATION_FEED_RSS = None
RSS_FEED_SUMMARY_ONLY = False

# Pagination
DEFAULT_PAGINATION = False

# Translations
DEFAULT_LANG = "en"