2023-12-15 10:30:18 -05:00

98 lines
2.0 KiB
Python

'''
Converts site content written in Markdown to HTML.
'''
class MarkdownContent(dict):
def __init__(self):
import frontmatter
import os
# content paths with metadata
self.PAGES_METADATA = dict()
self.FORMS_METADATA = dict()
for content_dir in self._CONTENT_DIRS:
self.__get_content(content_dir)
def __getitem__(self, page):
return self.METADATA[page]
def __content_page_faq(self):
'''
Fetch FAQ page content.
'''
return True
def __content_page_services(self):
'''
Fetch services page content.
'''
return True
def __content_page_about_me(self):
'''
Fetch about me page content.
'''
return True
def __content_page_contact_me(self):
'''
Fetch contact me page content.
'''
return True
def __content_form_meet_and_greet(self):
'''
Fetch meet & greet form content.
'''
return True
def __get_content(self, content_dir: str):
import frontmatter
import os
metadata = dict()
for items in os.walk(content_dir):
if len(items[2]) > 0:
for file in items[2]:
path = os.path.join(items[0], file)
metadata[path] = \
frontmatter.load(path).to_dict()
return metadata
def get_page(self, page: str):
'''
Transforms Markdown to HTML for pages.
'''
# match page.lower():
# case 'faq':
# return True
#
# case 'services':
# return True
#
# case 'about me':
# return True
#
# case 'contact me':
# return True
def get_form(self, form: str):
'''
Transforms Markdown to HTML for forms.
'''
# match form.lower():
# case 'meet and greet':
# return True