ブログ投稿のスタイリング

:discourse: 概要 Blog Post Styling(ブログ投稿スタイリング)を使用すると、ブログカテゴリを指定でき、そのカテゴリ内のトピックの外観が従来のブログ投稿のように変更されます。
:eyeglasses: プレビュー theme-creator.discourse.orgでプレビュー
:hammer_and_wrench: リポジトリ github.com/discourse/discourse-blog-post-styling
:open_book: Discourseテーマは初めてですか? Discourseテーマ使用の初心者ガイド

このテーマコンポーネントをインストール

Blog Post Stylingテーマコンポーネントは、Discourseのトピックを従来のブログ投稿レイアウトに変換します。カテゴリに適用すると、各トピックの最初の画像がタイトル上にフル幅のヒーローとして昇格され、コンテンツはブログに適したタイポグラフィとメタデータの表示でスタイル設定されます。

設定

このテーマコンポーネントに関連するさまざまな設定を以下に示します。

  • ブログカテゴリ: ブログ投稿スタイリングを使用するカテゴリのスラッグです。複数のカテゴリに追加するには、スペースなしのコンマ区切りリストを使用します(例:blog,announcements)。スラッグを見つけるには:

    • カテゴリの場合、/c/の後のURLパスを使用します。したがって、/c/blog/の場合、スラッグはblogです。
    • サブカテゴリの場合、/c/の後のURLパスを使用し、/-に置き換えます。たとえば、/c/blog/tutorialsにあるカテゴリはblog-tutorialsになります。
  • ブログタグ: トピックに適用されたときに、そのトピックにブログ投稿スタイリングを適用する1つ以上のタグを選択します。

  • 画像サイズ: ヒーロー画像がヘッダー領域をどのように埋めるかを決定します。

    • 画像なし: 特集画像を非表示にします。
    • フル幅(デフォルト): 画像がコンテンツ領域全体に広がります。
    • 中央揃え: 画像はアスペクト比を維持し、コンテンツ領域の中央に配置されます。
  • 画像の配置: タイトルに対して画像をどこに表示するかを決定します。

    • タイトルの上(デフォルト): 画像をトピックタイトルの上に表示します。
    • タイトルの下: 画像をトピックタイトルの下に表示します。これを選択すると、タイトルと画像の間に表示される要約を含めることもできます。以下では、画像の配置設定がタイトルの上タイトルの下に設定されている場合の画像の表示を確認できます。
  • ドロップキャップを有効にする: 有効にすると、ブログ投稿の最初の文字が拡大されたスタイルになります。例:
  • モバイルを有効にする: 有効にすると、モバイルデバイスでトピックを閲覧しているときにブログ投稿スタイリングが適用されます。

ブログ投稿の作成

ブログカテゴリを設定した(またはブログ投稿タグを適用した)後、ブログ投稿トピックの動作について注意すべき点がいくつかあります。

特集画像

ヒーロー画像として使用したい画像を、投稿の最初の行に配置し、その後にコンテンツを開始する前に空行を続けます。

![画像の簡単な説明|1100x440](upload://your-image-hash.jpg)

ここに投稿コンテンツが始まります...

コンポーネントは、画像の配置設定(上記参照)に基づいてこの画像を自動的に配置します。画像より前にコンテンツ(空行を含む)が表示されると、ヒーロー位置に昇格されません。

投稿を最初に公開した後、ページを更新して画像が指定された位置に表示されるようにします。(これは最初の公開時に投稿作成者にのみ影響します。投稿にアクセスするメンバーは、画像がすぐに正しい位置に表示されるはずです。)

画像サイジングのヒント

画像コンテナは高さ440px、**幅100%**です。画像サイズ設定がフル幅に設定されている場合の最良の結果を得るには:

  • アップロード前に画像を1100x400pxにトリミングまたは使用して、トリミングを回避するか、
  • 中央に被写体がある、または非特定のコンテンツ(風景、パターン)を持つ画像を選択し、トリミングによって重要な詳細が失われないようにします。

要約

画像の配置設定がタイトルの下に設定されている場合、ブログ投稿にオプションの要約を追加でき、これはタイトルと特集画像の間、またはタイトルと画像の間に表示されます。

これを行うには、要約として表示したいコンテンツを次のようにラップします。

[summary] ここが要約として表示されるコンテンツです。 [/summary]

スタイル付きブロッククォート

ブログカテゴリでトピックを作成する場合、ブロッククォートには特別なスタイルが適用されます。コンポーザーで>記号を使用するか、<kbd>“</kbd>コンポーザーツールバーボタンを使用してブロッククォートを作成できます。

推奨されるカテゴリ設定

ブログカテゴリの設定で、トピックが読み終わった後に最初の投稿に移動カテゴリ設定を有効にすることを検討してください。これにより、再訪問した読者は、最後に読んだ位置ではなく、ブログ投稿のコンテンツに直接移動します。

Blog Post Stylingとトピックリストサムネイル

このコンポーネントは、ブログ投稿の特集画像をトピックリストでハイライトするTopic List Thumbnailsと互換性があります。

注意: Topic List ThumbnailsコンポーネントはHorizonテーマとは互換性がありません。上記のスクリーンショットはFoundationテーマを使用しています。

「いいね!」 104

We just have been able to verify that by bumping the original markup materialized after upload by just injecting a zoom level of 101% at the appropriate place like

![image|690x458,101%](upload://4BWmapYzkwTQrWlm1JkeUwefYrC.jpeg)

after the respective image had been uploaded beforehand as

![image|690x458](upload://4BWmapYzkwTQrWlm1JkeUwefYrC.jpeg)

This is cute and makes us happy.


「いいね!」 3

Hello, and thank you very much for dedicating the time to create this and release it for free.

I was just wondering if it would be at all possible to change this somehow to use a specific tag instead of a particular category?

I just setup a new discourse website but I’ve been writing a lot of “blog posts” but I would still like these to show up in the appropriate other categories in order to make it seem a little more integrated.

Currently I have been posting them in their own blog-posts category, which I limited to just me being able to post in there, but I just setup a tag group and made that only accessible to staff.

Thanks again!

「いいね!」 3

Thanks very much @tshenry. Your theme components have all been spot on.And to @sam and @codinghorror for sharing an incredible app!! Your generosity including the support in meta is heartfelt. Discourse is indeed made for the more caring internet of the future.

「いいね!」 6

Is there a way to make this work with a video as the featured content rather than the image? I would delete my wordpress site if I could just post the YouTube/Vimeo etc. and have that be the top content. Any ideas?

「いいね!」 6

Totally! Great suggestion @LoganRTW. It’s got my vote @tshenry. Can it be done?

「いいね!」 4

Update :tada:

If you can believe it :sweat_smile:

I have started refactoring/cleaning up the component to use the plugin-style file structure and make use of the new topic thumbnails.

https://github.com/discourse/discourse/pull/9215

I’ve added a couple new features as well:

  • New settings
    • image_display_style - there are two options with this. The default should be the behavior the component has had all along. The alternative will ensure there is no cropping and the full image is displayed. It’s hard to say which one is “better” so you’ll want to do some experimentation and see what works best for your workflow and blog images.

    • mobile_enabled - this is a first pass on the mobile blog post style. I’m interested to hear any bug reports or ideas for improvements on this!

I still want to continue refactoring and cleaning up the code, but this should be a good start.

https://github.com/tshenry/discourse-blog-post-styling/commit/eba3c52fc1f9b273d34e9d673567410e4566372e


No plans at this point, I’m afraid!

「いいね!」 16

Thank you for a really inspiring and nice component @tshenry :pray:

In my evaluation I have identified two issues;

  1. No blog image in sub categories - after quite extensive troubleshooting with different themes and enabling/disabling both plugins and other components, I think I can state with near certainty that blog images won’t render for sub categories. The first image/the intended blog image is however still hidden.

  2. First image not hidden inline with DiscoTOC - When Blog Post Styling is used together with DiscoTOC, the blog image get rendered above the title correctly - however, it is rendered twice as it is still rendered in its original position as well.

「いいね!」 4

Thanks so much for the feedback @torstensson! Both points were indeed bugs and should now be fixed:

Please let me know if you continue to have any issues.


To everyone using this component:

:warning: If you are not currently including a featured image at the top of all blog posts, this is for you!

This component was created with the intention of having an image display above every blog post topic. With that said, it was possible to create a blog post without displaying a featured image by simply not including an image on the first line of the post. This behavior has changed.

The newer implementation greatly improves performance, but it uses a predefined value rather than looking at the post contents itself. The predefined value is generated from the first image found in the post. Unlike before, it is not necessarily limited to an image appearing as the first line of the post. This means if you create a post without an image on the first line, but you include a single image at the bottom of the post, that image at the bottom will now also be displayed above the topic.

I have included an all-or-nothing setting that can toggle on/off the “featured image,” allowing you to have all of the styling except for the featured image if that is your preference.

I am going to update the OP with all of the new considerations and recommendations, but the short of it is to make sure to include an image on the first line of the post (this positioning is still used to make sure the image is not repeated). You may find it is helpful to use a placeholder image in the category’s topic template that can be used as a default if no image is provided.

「いいね!」 6

Awesome, thank you @tshenry :awthanks: I can gladly confirm that both issues have been resolved with the update :slightly_smiling_face: and again - thank you for a really great component, not only in function but inspiration as well :+1: :+1:

「いいね!」 3

A recently announced feature may work as an alternative to this theme-component. Leaving it here for those interested.

「いいね!」 2

@tshenry Thanks so much for this component! :heart: We are using it along side the Topic List Previews plugin to create an Articles section for students in the Dataquest Community.

I have a feature request for you to consider in future iterations of this component - Can you please add the ability to add Canonical URLs to the articles?

Search engines use canonical links to determine and prioritize the ultimate source of content, removing confusion when there are multiple copies of the same document in different locations.

Thanks!

「いいね!」 3

So I think this is a great component. In fact I am now trying it out on a live Discourse and I am playing around with it. Without any kind of order, I want to provide my initial thoughts and feedback, hope it helps - forgive me if some of them might be more of a question:

  • The way the author is displayed is a bit out of place and could maybe be solved more space-efficient, to tie it in closer with the title, or category tag etc… there is also rather much white space between the line that ends the author info and the beginning of the text
  • It is hard for a vistor sent directly to a blog post to realize where you are, as there is no clear breadcrumb or anything. The main reason is, that the title bar seems to be turned inactive, whereas on normal topics they transform and include the title, category etc.
  • Would be great if the category view could have more of a blog look, with small preview images and such, would that be hard to do?
  • I don’t see a category description in the category view?
「いいね!」 2

wow what theme component is used for that category view? Looks cool

「いいね!」 2

Thanks for the feedback :slight_smile:

I do agree there is a lot of white space around the author/title area. I’ll keep this feedback in mind next time I work on the component and see if I can come up with something.

I’m not 100% sure what you mean here. The header will switch to include the title/breadcrumbs once you scroll down past the image and blog title. You are correct that at the top of the page, it’s not especially obvious, though. I’ll keep this in mind as well.

These would be out of scope for this component. For the category view, you might want to take a look at: Topic List Thumbnails

「いいね!」 2

Thanks for the feedback :slight_smile: I think most of it is cleared up, and I also do see the category description now, not sure why it wasn’t visible earlier, I thought it had something to do with the component. I will keep trying this out and post more feedback later. Excellent work!

「いいね!」 3

I think the excess space at the top comes from space remaining after the picture is “moved” to the header of the blogpost, resulting not in space below gained, but being empty.

But I noticed an actual problem: If I post links to such a blog post in other topics, there is no thumbnail, see here

「いいね!」 1

Here is a screenshot of what I mean:

「いいね!」 2

I’m fairly sure this is due to you excluding a line break between the image upload link and the first paragraph. Can you try editing it to match the following:

![spagh|690x390](upload://nVi42gGIwt03DAYSzVEc4RvwS6h.jpeg) 

<big>While</big> there is ample space around the web to post and blog and share and tweet and all that, my favorite place to exchange ideas with all of you on the spaghetti western is this forum. Some of you might remember an effort dating back several years ago, it was called "Planet Spaghetti Western", and the idea was to have a blog, that would automatically aggregate posts from all the spaghetti western blogs around the internet, and present them sort of as a digest. It was rather complicated from a technical perspective and in the end more work than it was worth so I had to shut that down.

If that works, I’ll add a note in the OP about that requirement.

「いいね!」 3

Hi. That reduces the margin a bit, indeed, thank you. I had done the exact opposite in the editor: leave as little space between the image and the beginning of the text

「いいね!」 1