Fixed RSS integration and added header configuration option

This commit is contained in:
Fabio Manganiello 2022-01-12 21:47:53 +01:00
parent 4a3cd0a88a
commit b256238d45
5 changed files with 16 additions and 4 deletions

View file

@ -1,3 +1,8 @@
# 0.1.2
- Fixed RSS feed support.
- Added `header` configuration option (the blog header can now be removed).
# 0.1.1 # 0.1.1
First usable version, with several bug fixes and better documentation. First usable version, with several bug fixes and better documentation.

View file

@ -70,6 +70,8 @@ home_link: https://link.to.home
logo: /path/or/url/here logo: /path/or/url/here
# Blog language (for the RSS feed) # Blog language (for the RSS feed)
language: en-US language: en-US
# Show/hide the header (default: true)
header: true
categories: categories:
- category1 - category1

View file

@ -86,8 +86,8 @@ class BlogApp(Flask):
def get_pages(self, with_content: bool = False, skip_header: bool = False) -> list: def get_pages(self, with_content: bool = False, skip_header: bool = False) -> list:
return sorted([ return sorted([
{ {
'path': path, 'path': path[len(app.pages_dir)+1:],
'content': self.get_page(path, skip_header=skip_header) if with_content else '', 'content': self.get_page(path[len(app.pages_dir)+1:], skip_header=skip_header) if with_content else '',
**self.get_page_metadata(os.path.basename(path)), **self.get_page_metadata(os.path.basename(path)),
} }
for path in glob(os.path.join(app.pages_dir, '*.md')) for path in glob(os.path.join(app.pages_dir, '*.md'))

View file

@ -12,6 +12,7 @@ class Config:
home_link = '/' home_link = '/'
language = 'en-US' language = 'en-US'
logo = '/img/icon.png' logo = '/img/icon.png'
header = True
content_dir = None content_dir = None
categories = None categories = None
@ -46,6 +47,8 @@ def init_config(content_dir='.', config_file='config.yaml'):
config.logo = cfg['logo'] config.logo = cfg['logo']
if cfg.get('language'): if cfg.get('language'):
config.language = cfg['language'] config.language = cfg['language']
if cfg.get('header') is False:
config.header = False
config.categories = cfg.get('categories', []) config.categories = cfg.get('categories', [])

View file

@ -16,12 +16,14 @@
<title>{{ title }}</title> <title>{{ title }}</title>
</head> </head>
<body> <body>
{% if not skip_header %} {% if not skip_header and config.header %}
<header> <header>
<div class="left"> <div class="left">
{% if config.logo %}
<a href="{{ config.home_link }}" title="Home"> <a href="{{ config.home_link }}" title="Home">
<img src="{{ config.logo }}" class="icon" alt="."> <img src="{{ config.logo }}" class="icon" alt="">
</a> </a>
{% endif %}
<a href="{{ config.link }}" title="{{ config.title }}"> <a href="{{ config.link }}" title="{{ config.title }}">
<span class="title">{{ config.title }}</span> <span class="title">{{ config.title }}</span>