トピックからトピックへのナビゲーションを作成する(シーケンス内の各トピックに自動的に「戻る/前」および「次へ/次」ボタンを挿入する)ために、私はこの方法で行っています…
「リンクされたトピックとして返信」を再利用し、リンクを次のようにCSSでスタイル設定しています…
そして、テーマ設定にいくつかのCSSを追加しています…
ボタンのみの最小限のCSS
.post-links-container {
margin-left: var(--topic-body-width-padding);
position: absolute;
top: 37px;
right: 30px;
}
.post-links-container ul li .d-icon {
display: none;
}
.post-links-container .post-links {
margin-top: 0;
padding-top: 0;
border-top: 0;
}
.post-links-container .post-links li:last-of-type {
margin-bottom: 0;
}
.post-links-container ul li a[href] {
align-items: center;
border: 1px solid var(--primary-low-mid);
background: var(--primary-very-low);
border-bottom-width: 2px;
border-radius: 3px;
box-sizing: border-box;
color: #009a49;
display: inline-flex;
font-family: monospace, monospace;
font-size: var(--font-down-1);
justify-content: center;
line-height: var(--line-height-large);
margin: 0 0.15em;
min-width: 24px;
padding: 0.15em 0.6em;
}
.post-links-container ul li a::after {
content: " ->>";
padding-left: 0.15em;
}
kbd {
align-items: center;
border: 1px solid var(--primary-low-mid);
background: var(--primary-very-low);
border-bottom-width: 2px;
border-radius: 3px;
box-sizing: border-box;
color: var(--primary);
display: inline-flex;
font-family: monospace, monospace;
font-size: var(--font-down-1);
justify-content: center;
line-height: var(--line-height-large);
margin: 0 0.15em;
min-width: 24px;
padding: 0.15em 0.6em;
}
kbd a {
padding: 0;
}
kbd a::before {
content: "<<-";
padding-right: 0.15em;
}
指示と私が使用している完全なCSS
/** 本やその他のトピックシーケンスのための前へ/次へボタン - この機能は、コンポーザー(左上)のネイティブDiscourse機能「リンクされたトピックとして返信」セレクターを再利用して構築されています。 **/
/** **あなたのDiscourseでこれを設定するには** **/
/** /admin/customize/site_texts/js.post.continue_discussion に **kbd**%{postLink}**kbd** を貼り付けます。 **/
/** 次に2つのカテゴリを作成します:BOOKS(ブログスタイルのトピックシーケンス用)とSTORIES(通常のトピックスタイルのトピックシーケンス用)。 **/
/** https://meta.discourse.org/t/blog-post-styling/110841 テーマコンポーネントをインストールします。 **/
/** ブログ投稿スタイリングテーマコンポーネントの設定で、BOOKSカテゴリ(STORIESは除く)をブログカテゴリとして割り当てます。 **/
/** 次に、BOOKというタグを作成し、それをブログ投稿スタイリングテーマコンポーネントの設定でブログタグとして割り当てます。 **/
/** 次に、以下のCSSを貼り付けるのを忘れないでください!これはテーマヘッダーに配置します。 **/
/** もちろん、ここのCSSは他のテーマで正しく機能するように調整する必要があります。 **/
/** これで、STORIESカテゴリにトピックのシーケンスを作成すると、ナビゲーションボタンが表示されますが、それらのトピックは通常のトピックとして表示されます)。 **/
/** BOOKタグを追加するだけで、これらのSTORIESカテゴリトピックにブログスタイリングを追加できます。 **/
/** BOOKSカテゴリで「リンクされたトピックとして返信」を使用して作成した新しいトピックには、ナビゲーションボタンとブログスタイリングの両方が既に表示されます。 **/
/** デモはこちらで確認できます:https://meta.discourse.org/t/is-pagination-impossible-or-just-hard/231838/16 **/
.tag-book,
.category-books {
aside.sidebar,
.topic-meta-data,
.tag-book .topic-category .badge-wrapper,
.category-books .topic-category .badge-wrapper {
display:none !important;
}
}
.tag-book .container.posts,
.category-books .container.posts {
justify-content: unset;
justify-items: unset;
padding-left: 0;
display: block;
}
.tag-book .container.posts .topic-post .row,
.category-books .container.posts .topic-post .row {
display: block;
justify-content: center;
}
.tag-book #topic-title .title-wrapper,
.category-books #topic-title .title-wrapper {
display: block;
margin: 0 auto;
}
.tag-book #topic-title,
.category-books #topic-title {
display: block;
margin: 0 auto;
}
.tag-book #topic-title h1,
.category-books #topic-title h1 {
font-size: 2em;
padding-right: 20px;
}
.tag-book #post_1 .topic-body,
.category-books #post_1 .topic-body {
padding-top: 1em;
border-top: none;
max-width: 100%;
}
.tag-book #post_1 .topic-body .contents,
.category-books #post_1 .topic-body .contents {
border-top: none;
margin-left: 0;
padding: 0;
}
.tag-book p,
.category-books p {
/* Bookのメインテキストのスタイルをここに記述 */
}
/* Forwardボタンをページの上部右側に配置 */
.tag-book .post-links-container,
.category-books .post-links-container {
margin-left: var(--topic-body-width-padding);
position: absolute;
top: 1em;
right: 30px;
}
/* Backボタンをページの上部左側に配置 */
.category-stories .post-links-container {
margin-left: var(--topic-body-width-padding);
position: absolute;
top: 2.5em;
right: 30px;
}
/* Forwardボタンのリンク記号を削除 */
.tag-book .post-links-container ul li .d-icon,
.category-books .post-links-container ul li .d-icon,
.category-stories .post-links-container ul li .d-icon {
display: none;
}
.tag-book .post-links-container .post-links,
.category-books .post-links-container .post-links,
.category-stories .post-links-container .post-links {
margin-top: 0;
padding-top: 0;
border-top: 0;
}
.tag-book .post-links-container .post-links li:last-of-type,
.category-books .post-links-container .post-links li:last-of-type,
.category-stories .post-links-container .post-links li:last-of-type {
margin-bottom: 0;
}
/* Next/Forwardボタンのスタイル */
.tag-book .post-links-container ul li a[href],
.category-books .post-links-container ul li a[href],
.category-stories .post-links-container ul li a[href] {
align-items: center;
border: 1px solid var(--primary-low-mid);
background: var(--primary-very-low);
border-bottom-width: 2px;
border-radius: 3px;
box-sizing: border-box;
color: #009a49;
display: inline-flex;
font-family: monospace, monospace;
font-size: var(--font-down-1);
justify-content: center;
line-height: var(--line-height-large);
margin: 0 0.15em;
min-width: 24px;
padding: 0.15em 0.6em;
}
/* Forwardボタンに右向きの矢印を追加 */
.tag-book .post-links-container ul li a::after,
.category-books .post-links-container ul li a::after,
.category-stories .post-links-container ul li a::after {
content: " ->>";
padding-left: 0.15em;
}
/* または右矢印に画像を使用 */
/*
.tag-book .post-links-container::after,
.category-books .post-links-container::after,
.category-stories .post-links-container::after {
content: url('../../media/arrow-right.svg');
display: inline-block;
width: 12px;
height: 12px;
}
*/
/* Back/Previousボタンのスタイル */
.tag-book kbd,
.category-books kbd,
.category-stories kbd {
align-items: center;
border: 1px solid var(--primary-low-mid);
background: var(--primary-very-low);
border-bottom-width: 2px;
border-radius: 3px;
box-sizing: border-box;
color: var(--primary);
display: inline-flex;
font-size: var(--font-down-1);
justify-content: center;
line-height: var(--line-height-large);
margin: 0;
min-width: 24px;
padding: 0.15em 0.6em;
}
.tag-book kbd a,
.category-books kbd a,
.category-stories kbd a {
padding: 0;
}
/* Backボタンに矢印を追加 */
.tag-book kbd a::before,
.category-books kbd a::before,
.category-stories kbd a::before {
content: "<<-";
padding-right: 0.15em;
}
/* または左矢印に画像を使用 */
/*
.tag-book kbd a::before,
.category-books kbd a::before,
.category-stories kbd a::before {
content: url('../../media/arrow-left.svg');
display: inline-block;
width: 12px;
height: 12px;
}
*/
結果は次のとおりです…
ライブでテストできます…



