Skip to content

Commit

Permalink
feat: content subscription page
Browse files Browse the repository at this point in the history
  • Loading branch information
Wivik committed Mar 24, 2024
1 parent 745aae2 commit f14eded
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 2 deletions.
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ The theme supports the following settings :
| `params.commission` | No | `false` | Display a button showing you're open for commissions. Possible values : `true` (commissions opened), `false` (commissions closed) |
| `params.commissionLink` | No | `none` | The link to your commission platform. |
| `params.contentLicense` | No | `none` | Display the license used for the website in the footer. Ex : CC BY-SA 4.0 |
| `params.displaySubscribeButton` | No | `true` | Display the RSS subscribe buttons on the About left section. The RSS link is for the books release. If the blog is enabled, another button will be display too. Same for the newsletter link. |
| `params.newsletterSubscriptionLink` | No | `none` | The link to your Newsletter subscription page. |
| `params.displaySubscribeButton` | No | `false` | Along with the usage of the `subscribe-example.md` page you would put in your `content` direct and rename, this option will enable a 'Subscribe' button redirecting to the subscribe page. See [Subscribe to the site's content](#subscribe-to-the-sites-content) for more details. |
| `params.displaySubscribeRSS` | No | `true` | Display the RSS subscribe buttons on the About left section. The RSS link is for the books release. If the blog is enabled, another button will be display too. Same for the newsletter link. |
| `params.goodreads` | No | `none` | Your GoodReads profile URL |
| `params.kofi` | No | `none` | Your Ko-fi profile URL |
| `params.mastodon` | No | `none` | The URL of your Mastodon profile. |
| `params.mastodonMaxItems` | No | `5` | How much posts you want to display in your feed. |
| `params.newsletterIntegrationCode` | No | `none` | Using the multiline yaml syntax to paste here the integration code for your newsletter subscription. |
| `params.newsletterSubscriptionLink` | No | `none` | The link to your Newsletter subscription page. **This setting has the precedence over the newsletter integration in the Susbcription page.** Meaning if you set both, the link to the newsletter subscription will be displayed but not the integrated form. |
| `params.pageCountisEstimated` | No | `false` | If set to true, this will add a small pop-up on the number of Pages displayed on the book details indicating the page count is an estimation. This is recommended if you only publish epub files because unlike physical copies, they does not have actual defined pages layout. <br>The default estimation is said to be based on 280 words per pages (see my [epub metadata exporter tool](https://github.com/Wivik/epub-metadata-exporter) for more). You may adapt this message in the `i18n` translation. |
| `params.patreon` | No | `none` | Your Patreon profile URL |
| `params.theme` | No | `nord` | Use one of the built-in themes :<br>- `nord`<br>- `catpuccin-latte`<br>- `catpuccin-frappe` |
Expand Down Expand Up @@ -256,6 +258,28 @@ Warning : in case of multilingual support, the article will have to be in all la
hugo new --kind blog blog/my-first-post.md
```

### Subscribe to the site's content

This feature was made to generate a "how to subscribe to this content" page. Basically, it's an agregate of your various communication channels for your audience.

To enable this feature, first you need to set `params.displaySubscribeButton` to `true` in `hugo.yaml`. The following button will appear :

[![subscribe](https://raw.githubusercontent.com/Wivik/am-writing-hugo-theme/main/images/subscribe-button.png)](https://raw.githubusercontent.com/Wivik/am-writing-hugo-theme/main/images/subscribe-button.png)

Then, mode `subscribe-example.md` available in with this theme to your `content/` folder and name it `subscribe.md`. Attention, if your site is multilingual, you need to copy it in each language folder. Such as `content/fr/subscribe.md` and `content/en/subscribe.md`.

[![subscribe](https://raw.githubusercontent.com/Wivik/am-writing-hugo-theme/main/images/subscribe-page-tn.png)](https://raw.githubusercontent.com/Wivik/am-writing-hugo-theme/main/images/subscribe-page.png)

This page is basically a list of Hugo Shortcodes that will display the following elements :

- `this_site` : a simple explanation about registering the site in the user's bookmarks.
- `rss_books` : a RSS feed for the books only
- `rss_blog` : a RSS feed for the [Blog](#blog) feature. Will be displayed only if the blog is enabled.
- `newsletter` : the integration code for your newsletter provider. Will integrate the code provided in `params.newsletterIntegrationCode`.
- `fediverse` : a link to your Mastodon account if defined in the settings.

All descriptions displayed in these pages can be overrided in the related `i18n` file.

## Books management

### Books page content
Expand Down
20 changes: 20 additions & 0 deletions i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ about:
subscribeBooksReleaseDescription: "Subscribe to the new books release using RSS."
subscribeBlogReleaseDescription: "Subscribe to the new blog articles using RSS."
subscribeNLDescription: "Subscribe to the new books notifications by e-mail."
subscribe: "Subscribe"
subscribeDescription: "Find how to subscribe to this website content."
newsletter: "E-mail"

subscribe:
title: "Subscribe to the news"
subscribe: "Subscribe"
descr: "Find here how to subscribe to this website content."
newsletter: "E-mail"
newsletterGDPR: "You messaging address will be used only to send you a notification when a new book is published. You may unsubscribe anytime by using the link available in the emails."
newsletterDescr: "Subscribe to the new books release by e-mail. This is not a newsletter, just a simple publication notice. Nothing more !"
thisSite: "This website"
thisSiteDescr: "You may follow this website content by just adding it in your bookmarks and consulting it regularly."
rssBooks: "Books RSS Feed"
rssBooksDescr: "If you use a RSS feed agregator, you may subscribe to the books release feed with the button below."
rssBlog: "Blog RSS Feed"
rssBlogDescr: "If you use a RSS feed agregator, you may subscribe to the blog article publications feed with the button below."
fediverse: "Fediverse"
fediverseDescr: "You can follow me on the Fediverse on my Mastodon account."


footer:
copyright: "All rights reserved."
Expand Down
18 changes: 18 additions & 0 deletions i18n/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,25 @@ about:
subscribeBooksReleaseDescription: "Suivez le fil RSS qui vous informera des nouveaux livres publiés."
subscribeBlogReleaseDescription: "Suivez le fil RSS des articles du blog."
subscribeNLDescription: "Inscrivez-vous aux notifications de nouvelles sorties par e-mail."
subscribe: "Suivre les nouveautés"
subscribeDescription: "Retrouvez comment suivre le contenu publié sur ce site."
newsletter: "E-mail"

subscribe:
title: "Suivre les nouveautés"
subscribe: "S'abonner"
descr: "Retrouvez comment suivre le contenu publié sur ce site."
newsletter: "E-mail"
newsletterDescr: "Abonnez-vous aux nouvelles publications de livres par e-mail. Ceci n'est pas une newsletter, mais une simple notification de sortie. Pas plus !"
newsletterGDPR: "Votre adresse de messagerie est uniquement utilisée pour vous envoyer une information lors de la publication d'un nouveau livre. Vous pouvez à tout moment utiliser le lien de désabonnement intégré dans chacun de nos mails."
thisSite: "Ce site web"
thisSiteDescr: "Vous pouvez suivre le contenu en mettant tout simplement ce site en favori et en le consultant régulièrement."
rssBooks: "Fil RSS des livres"
rssBooksDescr: "Si vous utilisez un agrégateur de fils RSS, vous pouvez souscrire a celui des publications de livres avec le bouton ci-dessous."
rssBlog: "Fil RSS du blog"
rssBlogDescr: "Si vous utilisez un agrégateur de fils RSS, vous pouvez souscrire a celui des publications des articles du blog avec le bouton ci-dessous."
fediverse: "Fediverse"
fediverseDescr: "Vous pouvez me suivre sur le Fediverse en vous abonnant à mon profil Mastodon."

footer:
copyright: "Tous droits réservés."
Expand Down
Binary file added images/subscribe-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/subscribe-page-tn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/subscribe-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions layouts/partials/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ <h1>{{ .Site.Params.author }}</h1>
{{ end }}
</p>

{{ $displaySubscribeButton := default .Site.Params.displaySubscribeButton true }}
{{ if $displaySubscribeButton }}
<p class="rss-subscribe">
<a href="{{ .Site.BaseURL }}{{ .Lang }}/subscribe/" rel="noopener noreferrer" class="support-button rss-button" title="{{ i18n "about.subscribeDescription" }}">{{ i18n "about.subscribe" }}</a>
</p>
{{ end }}

{{ if .Site.Params.patreon }}
<p>
<a href="{{ .Site.Params.patreon }}" rel="noopener noreferrer" class="support-button patreon-button">{{ i18n "about.patreon" }}</a>
Expand Down
9 changes: 9 additions & 0 deletions layouts/shortcodes/fediverse.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ if .Site.Params.mastodon }}
<h2>{{ i18n "subscribe.fediverse" }}</h2>

<p>{{ i18n "subscribe.fediverseDescr" }}</p>

<p>
<a href="{{ .Site.Params.mastodon }}" rel="noopener noreferrer" class="support-button rss-button" style="color: var(--body-font-color);">{{ i18n "home.followOnMastodon" }}</a>
</p>
{{ end }}
25 changes: 25 additions & 0 deletions layouts/shortcodes/newsletter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{ if or .Site.Params.newsletterIntegrationCode .Site.Params.newsletterSubscriptionLink }}
<h2>{{ i18n "subscribe.newsletter" }}</h2>

{{ if .Site.Params.newsletterSubscriptionLink }}

<p>{{ i18n "subscribe.newsletterDescr" }}</p>

<p>
<a href="{{ .Site.Params.newsletterSubscriptionLink }}" rel="noopener noreferrer" class="support-button rss-button" style="color: var(--body-font-color);" title="{{ i18n "about.subscribeNLDescription" }}">{{ i18n "subscribe.subscribe" }}</a>
</p>

<p>{{ i18n "subscribe.newsletterGDPR" }}</p>

{{ else }}

<p>{{ i18n "subscribe.newsletterDescr" }}</p>

<p>
{{ .Site.Params.newsletterIntegrationCode | safeHTML }}
</p>

<p>{{ i18n "subscribe.newsletterGDPR" }}</p>

{{ end }}
{{ end }}
9 changes: 9 additions & 0 deletions layouts/shortcodes/rss_blog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ if .Site.Params.blog }}
<h2>{{ i18n "subscribe.rssBlog" }}</h2>

<p>{{ i18n "subscribe.rssBlogDescr" }}</p>

<p>
<a href="{{ .Site.BaseURL }}{{ .Page.Lang }}/blog/index.xml" rel="noopener noreferrer" class="support-button rss-button" style="color: var(--body-font-color);" title="{{ i18n "about.subscribeBlogReleaseDescription" }}">{{ i18n "subscribe.subscribe" }}</a>
</p>
{{ end }}
7 changes: 7 additions & 0 deletions layouts/shortcodes/rss_books.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h2>{{ i18n "subscribe.rssBooks" }}</h2>

<p>{{ i18n "subscribe.rssBooksDescr" }}</p>

<p>
<a href="{{ .Site.BaseURL }}{{ .Page.Lang }}/books/index.xml" rel="noopener noreferrer" class="support-button rss-button" style="color: var(--body-font-color);" title="{{ i18n "about.subscribeBooksReleaseDescription" }}">{{ i18n "subscribe.subscribe" }}</a>
</p>
3 changes: 3 additions & 0 deletions layouts/shortcodes/this_site.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h2>{{ i18n "subscribe.thisSite" }}</h2>

<p>{{ i18n "subscribe.thisSiteDescr" }}</p>
15 changes: 15 additions & 0 deletions subscribe-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "Subscribe to the content"
---

{{< i18n "subscribe.descr" >}}

{{< this_site >}}

{{< rss_books >}}

{{< rss_blog >}}

{{< newsletter >}}

{{< fediverse >}}

0 comments on commit f14eded

Please sign in to comment.