Adding article icon tags (fixes #12)

This commit is contained in:
Jean Viscogliosi-Pate 2025-11-13 19:02:59 -08:00
parent c127440172
commit 38d4cd029b
7 changed files with 56 additions and 13 deletions

View File

@ -19,15 +19,18 @@ The maximum width that an image will be rendered at is 1200px. 1200px wide by 22
Internal tags can be added from the Tags page in Ghost's admin interface. All internal tags are prefixed with a hash. Tag behavior in this theme is dependent on whether it has an associated image. Internal tags can be added from the Tags page in Ghost's admin interface. All internal tags are prefixed with a hash. Tag behavior in this theme is dependent on whether it has an associated image.
### How to add an icon before a post's title
- The **Tag image** field is the icon file. This is assumed to be an SVG with an `id` matching the tag's **Meta description**. The SVG must be structured this way to support `fill=currentColor`, which enables the icon to be themed with the website.
- The **Meta title** field is used for the image title and alt text.
### How to add text after a post's title ### How to add text after a post's title
Do not add an image to your internal tag. Only the **Description** field is used. Do not add an image to your internal tag. Only the **Description** field is used.
### How to add icons above a post's title ### How to add icons above a post's title
- The **Tag image** field is the icon file. This is assumed to be an SVG with an `id` matching the tag's **Meta description**. The SVG must be structured this way to support `fill=currentColor`, which enables the icon to be themed with the website. In addition to the fields for an icon before a post's title, a **Description** field must be provided. The provided description text will follow the icon.
- The **Meta title** field is used for the image title and alt text.
- The **Description** field is the text that accompanies the icon, if present.
### How to hide publication date and/or table of contents ### How to hide publication date and/or table of contents

View File

@ -326,6 +326,23 @@ hr {
display: inline; display: inline;
} }
.tag-post-icon {
color: var(--color-primary-text);
float: left;
}
.gh-article-title .tag-post-icon {
width: var(--big-title-font-size);
height: var(--big-title-font-size);
margin-right: 15px;
}
.gh-card-title .tag-post-icon {
width: var(--title-font-size);
height: var(--title-font-size);
margin-right: 10px;
}
/* Feed /* Feed
/* ---------------------------------------------------------- */ /* ---------------------------------------------------------- */

View File

@ -1,7 +1,7 @@
{ {
"name": "bifocal", "name": "bifocal",
"description": "A Ghost theme, based on Solo", "description": "A Ghost theme, based on Solo",
"version": "1.0.4", "version": "1.0.5",
"private": true, "private": true,
"engines": { "engines": {
"ghost": ">=5.0.0" "ghost": ">=5.0.0"

View File

@ -4,15 +4,17 @@
<ul class="tag-list"> <ul class="tag-list">
{{#foreach tags visibility="internal"}} {{#foreach tags visibility="internal"}}
{{#if feature_image}} {{#if feature_image}}
<li> {{#if description}}
<svg class="tag-icon" role="img" title="{{meta_title}}" alt="{{meta_title}}"> <li>
<use href="{{img_url feature_image}}#{{meta_description}}"> <svg class="tag-icon" role="img" title="{{meta_title}}" alt="{{meta_title}}">
</svg> <use href="{{img_url feature_image}}#{{meta_description}}">
</svg>
<div class="tag-text"> <div class="tag-text">
<p>{{description}}</p> <p>{{description}}</p>
</div> </div>
</li> </li>
{{/if}}
{{/if}} {{/if}}
{{/foreach}} {{/foreach}}

View File

@ -0,0 +1,13 @@
{{!-- Used for de-emphasized text after post title --}}
{{#if tags}}
{{#foreach tags visibility="internal"}}
{{^if description}}
{{#if feature_image}}
<svg class="tag-post-icon" role="img" title="{{meta_title}}" alt="{{meta_title}}">
<use href="{{img_url feature_image}}#{{meta_description}}">
</svg>
{{/if}}
{{/if}}
{{/foreach}}
{{/if}}

View File

@ -22,6 +22,7 @@
</div> </div>
<h2 class="gh-card-title"> <h2 class="gh-card-title">
{{> "get-post-icon"}}
{{title}} {{title}}
<div class="tag-desc"> <div class="tag-desc">
{{> "get-desc-tags"}} {{> "get-desc-tags"}}

View File

@ -11,6 +11,7 @@
{{#if feature_image}} {{#if feature_image}}
<header class="gh-article-header gh-canvas"> <header class="gh-article-header gh-canvas">
<h1 class="gh-article-title"> <h1 class="gh-article-title">
{{> "get-post-icon"}}
{{title}} {{title}}
<div class="tag-desc"> <div class="tag-desc">
{{> "get-desc-tags"}} {{> "get-desc-tags"}}
@ -31,7 +32,13 @@
{{#unless feature_image}} {{#unless feature_image}}
<header class="gh-article-header"> <header class="gh-article-header">
<h1 class="gh-article-title">{{title}}</h1> <h1 class="gh-article-title">
{{> "get-post-icon"}}
{{title}}
<div class="tag-desc">
{{> "get-desc-tags"}}
</div>
</h1>
{{#if custom_excerpt}} {{#if custom_excerpt}}
<p class="gh-article-excerpt">{{custom_excerpt}}</p> <p class="gh-article-excerpt">{{custom_excerpt}}</p>
{{/if}} {{/if}}