Template:BookCard: Difference between revisions

From WikiProducers
Created page with "{{#invoke:String|clean}}<!-- keeps tidy in some setups --> <div class="wp-book" role="region" aria-label="Book: {{{title|}}}"> <img class="wp-book__cover" src="{{{cover|}}}" alt="Book cover: {{{title|}}} by {{{author|}}}"> <div> <h3 class="wp-book__title">{{{title|Untitled}}}</h3> <p class="wp-book__meta">{{{author|Unknown}}}{{#if:{{{pages|}}}| · {{{pages}}} pages}}{{#if:{{{year|}}}| · {{{year}}}}}</p> <p class="wp-book__desc">{{{descript..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{#invoke:String|clean}}<!-- keeps tidy in some setups -->
<noinclude>
{{#template_params:title|author|pages|year|description|cover|link|cta|tag|stars}}
{{#cargo_declare:_table=BookCard|title=String|author=String|pages=Page|year=Page|description=String (allowed values=cover)|cover=String|link=String|cta=String|tag=String|stars=String}}
</noinclude><includeonly>{{#cargo_store:_table=BookCard}}
{{#template_display:_format=infobox}}</includeonly>


<div class="wp-book" role="region" aria-label="Book: {{{title|}}}">
{
  <img class="wp-book__cover"
  "description": "Reusable book card with Amazon affiliate link",
      src="{{{cover|}}}"
  "params": {
      alt="Book cover: {{{title|}}} by {{{author|}}}">
    "title": {
  <div>
      "label": "Book Title",
     <h3 class="wp-book__title">{{{title|Untitled}}}</h3>
      "type": "string",
     <p class="wp-book__meta">{{{author|Unknown}}}{{#if:{{{pages|}}}| · {{{pages}}} pages}}{{#if:{{{year|}}}| · {{{year}}}}}</p>
      "required": true
     <p class="wp-book__desc">{{{description|}}}</p>
    },
    <div class="wp-book__footer">
    "author": {
       {{#if:{{{link|}}}|
      "label": "Author",
       <a class="wp-book__btn"
      "type": "string"
        href="{{{link}}}"
    },
        rel="sponsored nofollow noopener noreferrer"
     "pages": {
        target="_blank"
      "label": "Pages",
        aria-label="View on Amazon (affiliate link)">
      "type": "number"
        {{#if:{{{cta|}}}|{{{cta}}}|View on Amazon}}
    },
       </a>}}
     "year": {
       {{#if:{{{tag|}}}|<span class="wp-book__pill">{{{tag}}}</span>}}
      "label": "Year",
       {{#if:{{{stars|}}}|<span class="wp-book__stars" aria-label="Average rating {{{stars}}} out of 5">
      "type": "number"
        {{{stars}}}
    },
       </span>}}
     "description": {
     </div>
      "label": "Description",
   </div>
       "type": "string",
</div>
       "multiline": true
    },
    "cover": {
      "label": "Cover Image URL",
      "type": "string"
    },
    "link": {
      "label": "Amazon Link",
      "type": "string"
    },
    "cta": {
       "label": "Button Text",
       "type": "string"
    },
    "tag": {
       "label": "Category Tag",
      "type": "string"
    },
    "stars": {
      "label": "Rating",
       "type": "string"
     }
   }
}

Latest revision as of 10:00, 16 August 2025

This is the "BookCard" template.

It should be called in the following format:

{{BookCard
|title=
|author=
|pages=
|year=
|description=
|cover=
|link=
|cta=
|tag=
|stars=
}}

Edit the page to see the template text.

{{#cargo_declare:_table=BookCard|title=String|author=String|pages=Page|year=Page|description=String (allowed values=cover)|cover=String|link=String|cta=String|tag=String|stars=String}}


{

 "description": "Reusable book card with Amazon affiliate link",
 "params": {
   "title": {
     "label": "Book Title",
     "type": "string",
     "required": true
   },
   "author": {
     "label": "Author",
     "type": "string"
   },
   "pages": {
     "label": "Pages",
     "type": "number"
   },
   "year": {
     "label": "Year",
     "type": "number"
   },
   "description": {
     "label": "Description",
     "type": "string",
     "multiline": true
   },
   "cover": {
     "label": "Cover Image URL",
     "type": "string"
   },
   "link": {
     "label": "Amazon Link",
     "type": "string"
   },
   "cta": {
     "label": "Button Text",
     "type": "string"
   },
   "tag": {
     "label": "Category Tag",
     "type": "string"
   },
   "stars": {
     "label": "Rating",
     "type": "string"
   }
 }

}