From 6d159c8fddb901437249c69dc1ef4afc30c905d0 Mon Sep 17 00:00:00 2001 From: Bruno Rocha Date: Wed, 13 Nov 2024 17:28:19 +0000 Subject: [PATCH] feat: author and multi author support fix #83 --- example/content/2024-10-24-getting-started.md | 1 + example/content/markdown-format.md | 16 +- example/marmite.yaml | 15 ++ example/static/marmite.css | 230 +++++++++++++++++- example/templates/content.html | 18 +- example/templates/content_authors.html | 15 ++ example/templates/content_date.html | 6 + example/templates/content_title.html | 8 + example/templates/list.html | 24 +- src/config.rs | 15 ++ src/content.rs | 22 ++ src/markdown.rs | 6 +- src/site.rs | 34 +++ 13 files changed, 398 insertions(+), 12 deletions(-) create mode 100644 example/templates/content_authors.html create mode 100644 example/templates/content_date.html create mode 100644 example/templates/content_title.html diff --git a/example/content/2024-10-24-getting-started.md b/example/content/2024-10-24-getting-started.md index c45cd42..f392e69 100644 --- a/example/content/2024-10-24-getting-started.md +++ b/example/content/2024-10-24-getting-started.md @@ -4,6 +4,7 @@ slug: getting-started tags: docs extra: mermaid: true +authors: rochacbruno --- Learn how to create your blog with Marmite in minutes, you can start with zero-config and then customize gradually later. diff --git a/example/content/markdown-format.md b/example/content/markdown-format.md index 369574d..83e22e6 100644 --- a/example/content/markdown-format.md +++ b/example/content/markdown-format.md @@ -4,19 +4,25 @@ date: 2024-10-17 12:00:01 slug: markdown-format description: The content here accepts any valid CommonMark or Github Flavoured markdown and some GFM extensions. tags: docs, markdown, Common Mark, GFM +authors: rochacbruno,karlamagueta extra: math: true mermaid: true - mermaid_theme: neutral + mermaid_theme: default --- -# Writing content in Markdown +The content on Marmite accepts any valid `CommonMark` or **Github** _Flavoured_ markdown +and some `GFM` extensions, Marmite also does post processing of HTML to support features such as +back-links and Obsidian links. -The content here accepts any valid `CommonMark` or **Github** _Flavoured_ markdown -and some `GFM` extensions. +### Paragraphs and formatting Simple paragraph and usual formatting like **bold**, __underline__, *italic* -and also all sorts of formatting elements. +and also all sorts of formatting elements, as follows. + +```markdown +**bold**, __underline__, *italic* +``` ### Strike-through diff --git a/example/marmite.yaml b/example/marmite.yaml index 2ede3ae..c14c539 100644 --- a/example/marmite.yaml +++ b/example/marmite.yaml @@ -25,6 +25,21 @@ menu: - ["Github", "https://github.com/rochacbruno/marmite"] default_date_format: "%A, %d %B" + +authors: + rochacbruno: + name: Bruno Rocha + avatar: https://github.com/rochacbruno.png + bio: Marmite Maintainer + links: + - ["Fediverse", "https://go.rocha.social/@bruno"] + - ["Github", "https://github.com/rochacbruno"] + - ["Linkedin", "https://www.linkedin.com/in/rochacbruno/"] + - ["Links", "https://bruno.rocha.social"] + karlamagueta: + name: Karla Magueta + avatar: https://github.com/karlamagueta.png + # extra data for template customization # extra: # foo: bar diff --git a/example/static/marmite.css b/example/static/marmite.css index e6e38fc..d46de02 100644 --- a/example/static/marmite.css +++ b/example/static/marmite.css @@ -207,7 +207,11 @@ article footer { } pre:has(> code.language-mermaid) { - background-color: transparent; + background-color: #fff; +} + +pre:has(> code.language-mermaid) p { + color: revert; } /* Search */ @@ -384,4 +388,226 @@ pre:has(> code.language-mermaid) { .search-magnifier { display: none; } -} \ No newline at end of file +} + +.content-title { + margin-bottom: 10px; +} +.content-title h1 { + margin: 0; +} + +.content-authors { + display: flex; + flex-wrap: wrap; + gap: 8px; + margin-left: 8px; +} + +.content-authors img { + width: 40px; + height: 40px; + border-radius: 50%; +} + +.content-authors p { + margin: 0; +} + +.content-authors ul { + list-style: none; + padding: 0; + margin-top: revert; +} + +.content-authors li { + display: flex; + align-items: center; +} + +td, th { + padding: calc(var(--pico-spacing)/ 2) var(--pico-spacing); + border: var(--pico-border-width) solid var(--pico-table-border-color); + background-color: var(--pico-background-color); + color: var(--pico-color); + font-weight: var(--pico-font-weight); + /* text-align: left; */ + text-align: start; +} + + +/*
+
+

{{author.name}}

+ {{ author.name }} +

{{author.bio}}

+ {% if author.links %} +
    + {% for link in author.links %} +
  • {{link.0}}
  • + {% endfor %} + {% endif %} +
+
*/ + +/* .author-hero { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + margin: 20px 0; +} + +.author-hero h1 { + margin-bottom: 20px; +} + +.author-hero article { + display: flex; + flex-direction: column; + align-items: center; +} + +.author-hero img.avatar { + width: 150px; + height: 150px; + border-radius: 50%; + margin-bottom: 20px; +} + +.author-hero p { + margin-bottom: 20px; +} + +.author-hero ul { + display: flex; + gap: 10px; + list-style: none; + padding: 0; + margin: 0; +} + +.author-hero ul li { + display: inline; +} + +.author-hero ul li a { + text-decoration: none; + color: var(--pico-color-azure-550); + transition: color 0.3s ease; +} + +.author-hero ul li a:hover { + color: var(--pico-color-azure-650); +} + +@media (min-width: 768px) { + .author-hero article { + flex-direction: row; + align-items: flex-start; + text-align: left; + } + + .author-hero img.avatar { + margin-right: 20px; + margin-bottom: 0; + } + + .author-hero p { + flex: 1; + } + + .author-hero ul { + justify-content: flex-start; + } +} */ + + + +/* + +
+
+

{{author.name}}

+
+ {{ author.name }} +
+
+

{{author.bio}}

+
+ {% if author.links %} + + {% endif %} +
+
+*/ +.author-hero { + padding: 20px; +} + +.author-hero article { + display: grid; + grid-template-areas: + "title title" + "image bio" + "links links"; + gap: 20px; + grid-template-columns: auto 1fr; +} + +.author-hero h1 { + grid-area: title; + margin: 0; +} + +.author-hero-image { + grid-area: image; +} + +.author-hero-image .avatar { + width: 100px; + height: 100px; + border-radius: 50%; +} + +.author-hero-bio { + grid-area: bio; +} + +.author-hero-links { + grid-area: links; +} + +.author-hero-links ul { + display: flex; + gap: 15px; + padding: 0; + list-style: none; +} + +.author-hero-links ul li{ + list-style: none; +} + +.author-hero-links a { + color: var(--pico-color-azure-550); +} + +@media (max-width: 768px) { + .author-hero article { + grid-template-areas: + "title" + "image" + "bio" + "links"; + grid-template-columns: 1fr; + text-align: center; + } +} + diff --git a/example/templates/content.html b/example/templates/content.html index 74eb0a8..5c4fdd0 100644 --- a/example/templates/content.html +++ b/example/templates/content.html @@ -37,12 +37,24 @@ {% endblock %} + {% block main %} + +{# +
+{% if content.card_image %} {{content.title}} {% endif %} +
+#} +
-
{{ content.html | safe }}
+ + {% include "content_title.html" ignore missing %} + +
{{ content.html }}
{% if content.date %}