| 1 | package App::Dapper::Theme::Business; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | App::Dapper::Theme::Business - A small business starter for "dapper init --template business". | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | A home page with services, opening hours and contact details, a news section, | ||
| 10 | and about and contact pages. Everything about the business (its address, | ||
| 11 | hours and services) lives in one data file, C<_data/business.yml>, which also | ||
| 12 | feeds the structured data search engines and AI tools read. | ||
| 13 | |||
| 14 | =cut | ||
| 15 | |||
| 16 | 32 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 32 | ▶ | use 5.010; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 32 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 32 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | |||
| 21 | =head2 description | ||
| 22 | |||
| 23 | A one-line description of the theme. | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | 32 | ▶ | sub description { 'A small business: services, opening hours, contact details and news, from one data file' } |
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||
| 28 | |||
| 29 | =head2 notes | ||
| 30 | |||
| 31 | Notes about the theme for AGENTS.md. | ||
| 32 | |||
| 33 | =cut | ||
| 34 | |||
| 35 | 32 | ▶ | sub notes { |
|
Subroutine
notes: called CC=1 SCAR=0.0
Pod
documented
| |||
| 36 | 32 | return <<'NOTES'; | |
| 37 | ## About this business site | ||
| 38 | |||
| 39 | - **Everything about the business is in `_data/business.yml`:** name, tagline, | ||
| 40 | phone, email, address, opening hours and services. Change it there and every | ||
| 41 | page (and the structured data search engines read) updates. Don't copy these | ||
| 42 | details into pages. | ||
| 43 | - Hours are a list of `days` and `hours` (`hours: Closed` for closed days); | ||
| 44 | holiday changes go in `notice`, which shows as a banner on every page. | ||
| 45 | - News posts go in `_source/news/` with `layout: post`, `categories: news`, a | ||
| 46 | `title`, a `date` and a `description`. The news page (`_source/news.html`) lists them, newest first. | ||
| 47 | NOTES | ||
| 48 | } | ||
| 49 | |||
| 50 | =head2 files | ||
| 51 | |||
| 52 | Returns the theme's files, as a hash of path to content. | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | 32 | ▶ | sub files { |
|
Subroutine
files: called CC=1 SCAR=0.0
Pod
documented
| |||
| 57 | return { | ||
| 58 | 32 | '_config.yml' => <<'FILE', | |
| 59 | # Dapper configuration file. See https://github.com/markdbenson/dapper | ||
| 60 | --- | ||
| 61 | name: Hearth & Crumb Bakery | ||
| 62 | description: A neighborhood bakery making sourdough, pastries and coffee every morning. | ||
| 63 | author: Hearth & Crumb Bakery | ||
| 64 | |||
| 65 | # The address the site will be published at, without a trailing slash. | ||
| 66 | url: https://example.com | ||
| 67 | |||
| 68 | image: /images/storefront.svg | ||
| 69 | timezone: America/Chicago | ||
| 70 | |||
| 71 | feed: | ||
| 72 | category: news | ||
| 73 | |||
| 74 | # Where "dapper deploy" publishes the site. Uncomment "deploy:" and one | ||
| 75 | # of the targets below. See "Deploying with dapper deploy" in the README. | ||
| 76 | #deploy: | ||
| 77 | # s3: | ||
| 78 | # bucket: example.com | ||
| 79 | # github_pages: | ||
| 80 | # branch: gh-pages | ||
| 81 | # command: rsync -av --delete _output/ me@example.com:/var/www/site/ | ||
| 82 | FILE | ||
| 83 | |||
| 84 | '_data/business.yml' => <<'FILE', | ||
| 85 | # Everything about the business, used on every page (site.data.business) | ||
| 86 | name: Hearth & Crumb Bakery | ||
| 87 | tagline: Bread, pastries and coffee, baked here every morning. | ||
| 88 | phone: (312) 555-0142 | ||
| 89 | email: hello@example.com | ||
| 90 | address: | ||
| 91 | street: 1418 W Division St | ||
| 92 | city: Chicago | ||
| 93 | region: IL | ||
| 94 | postcode: "60642" | ||
| 95 | country: US | ||
| 96 | map: https://www.openstreetmap.org/search?query=1418%20W%20Division%20St%20Chicago | ||
| 97 | |||
| 98 | # A short notice shown at the top of every page, such as holiday hours. | ||
| 99 | # Leave it empty when there is nothing to say. | ||
| 100 | notice: "" | ||
| 101 | |||
| 102 | hours: | ||
| 103 | - days: Tuesday to Friday | ||
| 104 | hours: 7am to 3pm | ||
| 105 | - days: Saturday and Sunday | ||
| 106 | hours: 8am to 2pm | ||
| 107 | - days: Monday | ||
| 108 | hours: Closed | ||
| 109 | |||
| 110 | services: | ||
| 111 | - name: Sourdough | ||
| 112 | description: Country loaves, rye and seeded sourdough, from our own starter. | ||
| 113 | - name: Pastries | ||
| 114 | description: Croissants, cardamom buns and seasonal fruit tarts. | ||
| 115 | - name: Coffee | ||
| 116 | description: Espresso and filter coffee from a roaster down the street. | ||
| 117 | - name: Special orders | ||
| 118 | description: Birthday cakes and catering trays, with three days' notice. | ||
| 119 | FILE | ||
| 120 | |||
| 121 | '_layout/index.html' => <<'FILE', | ||
| 122 | --- | ||
| 123 | description: The page wrapper used by every page (header, notice, footer with hours and address, SEO tags) | ||
| 124 | --- | ||
| 125 | [% b = site.data.business %]<!DOCTYPE html> | ||
| 126 | <html lang="en"> | ||
| 127 | <head> | ||
| 128 | <meta charset="utf-8"> | ||
| 129 | <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| 130 | <title>[% IF page.title AND page.url != '/' %][% page.title | html %] - [% END %][% b.name | html %]</title> | ||
| 131 | [% page.seo %] | ||
| 132 | [% ld = { | ||
| 133 | '@context' => 'https://schema.org', | ||
| 134 | '@type' => 'LocalBusiness', | ||
| 135 | 'name' => b.name, | ||
| 136 | 'description' => site.description, | ||
| 137 | 'url' => site.url, | ||
| 138 | 'telephone' => b.phone, | ||
| 139 | 'email' => b.email, | ||
| 140 | 'address' => { | ||
| 141 | '@type' => 'PostalAddress', | ||
| 142 | 'streetAddress' => b.address.street, | ||
| 143 | 'addressLocality' => b.address.city, | ||
| 144 | 'addressRegion' => b.address.region, | ||
| 145 | 'postalCode' => b.address.postcode, | ||
| 146 | 'addressCountry' => b.address.country, | ||
| 147 | }, | ||
| 148 | } %] | ||
| 149 | <script type="application/ld+json">[% ld.json %]</script> | ||
| 150 | <link rel="stylesheet" href="/css/site.css"> | ||
| 151 | </head> | ||
| 152 | <body> | ||
| 153 | <a class="skip" href="#main">Skip to content</a> | ||
| 154 | [% IF b.notice %] | ||
| 155 | <p class="notice" role="status">[% b.notice | html %]</p> | ||
| 156 | [% END %] | ||
| 157 | <header class="site-header"> | ||
| 158 | <a class="site-name" href="/">[% b.name | html %]</a> | ||
| 159 | <nav aria-label="Main"> | ||
| 160 | <a href="/">Home</a> | ||
| 161 | <a href="/news.html">News</a> | ||
| 162 | <a href="/about.html">About</a> | ||
| 163 | <a href="/contact.html">Contact</a> | ||
| 164 | </nav> | ||
| 165 | </header> | ||
| 166 | <main id="main"> | ||
| 167 | [% page.content %] | ||
| 168 | </main> | ||
| 169 | <footer class="site-footer"> | ||
| 170 | <div> | ||
| 171 | <h2>Hours</h2> | ||
| 172 | <dl class="hours"> | ||
| 173 | [% FOR row IN b.hours %] | ||
| 174 | <dt>[% row.days | html %]</dt><dd>[% row.hours | html %]</dd> | ||
| 175 | [% END %] | ||
| 176 | </dl> | ||
| 177 | </div> | ||
| 178 | <div> | ||
| 179 | <h2>Visit</h2> | ||
| 180 | <address> | ||
| 181 | [% b.address.street | html %]<br> | ||
| 182 | [% b.address.city | html %], [% b.address.region | html %] [% b.address.postcode | html %]<br> | ||
| 183 | <a href="tel:[% b.phone | html %]">[% b.phone | html %]</a><br> | ||
| 184 | <a href="mailto:[% b.email | html %]">[% b.email | html %]</a> | ||
| 185 | </address> | ||
| 186 | </div> | ||
| 187 | <p class="copyright">© [% site.time.year %] [% b.name | html %]</p> | ||
| 188 | </footer> | ||
| 189 | </body> | ||
| 190 | </html> | ||
| 191 | FILE | ||
| 192 | |||
| 193 | '_layout/post.html' => <<'FILE', | ||
| 194 | --- | ||
| 195 | layout: index | ||
| 196 | description: A news post | ||
| 197 | --- | ||
| 198 | <article class="prose"> | ||
| 199 | <h1>[% page.title | html %]</h1> | ||
| 200 | <p class="meta">[% page.date.strftime('%d %B %Y') %]</p> | ||
| 201 | [% page.content %] | ||
| 202 | <p><a href="/news.html">← All news</a></p> | ||
| 203 | </article> | ||
| 204 | FILE | ||
| 205 | |||
| 206 | '_source/index.html' => <<'FILE', | ||
| 207 | --- | ||
| 208 | title: Home | ||
| 209 | description: A neighborhood bakery in Chicago making sourdough, pastries and coffee every morning. | ||
| 210 | template: true | ||
| 211 | --- | ||
| 212 | [% b = site.data.business %] | ||
| 213 | <section class="hero"> | ||
| 214 | <img src="/images/storefront.svg" alt="The front of the bakery, with loaves in the window" width="1200" height="600"> | ||
| 215 | <div> | ||
| 216 | <h1>[% b.tagline | html %]</h1> | ||
| 217 | <p><a class="button" href="/contact.html">Find us</a></p> | ||
| 218 | </div> | ||
| 219 | </section> | ||
| 220 | |||
| 221 | <section aria-labelledby="services"> | ||
| 222 | <h2 id="services">What we make</h2> | ||
| 223 | <ul class="services" role="list"> | ||
| 224 | [% FOR s IN b.services %] | ||
| 225 | <li> | ||
| 226 | <h3>[% s.name | html %]</h3> | ||
| 227 | <p>[% s.description | html %]</p> | ||
| 228 | </li> | ||
| 229 | [% END %] | ||
| 230 | </ul> | ||
| 231 | </section> | ||
| 232 | |||
| 233 | [% IF site.categories.news %] | ||
| 234 | <section aria-labelledby="latest"> | ||
| 235 | <h2 id="latest">Latest news</h2> | ||
| 236 | [% FOR post IN site.categories.news.reverse %][% LAST IF loop.count > 3 %] | ||
| 237 | <p><a href="[% post.url %]">[% post.title | html %]</a> <span class="meta">[% post.date.strftime('%d %B') %]</span></p> | ||
| 238 | [% END %] | ||
| 239 | </section> | ||
| 240 | [% END %] | ||
| 241 | FILE | ||
| 242 | |||
| 243 | '_source/about.md' => <<'FILE', | ||
| 244 | --- | ||
| 245 | title: About | ||
| 246 | description: The story of Hearth & Crumb, a neighborhood bakery in Chicago. | ||
| 247 | --- | ||
| 248 | |||
| 249 | # About us | ||
| 250 | |||
| 251 | We opened Hearth & Crumb in 2019 with one oven and a sourdough starter called | ||
| 252 | Gus. We still bake everything here, every morning, and we still feed Gus. | ||
| 253 | |||
| 254 | Edit `_source/about.md` to tell your own story. | ||
| 255 | FILE | ||
| 256 | |||
| 257 | '_source/contact.html' => <<'FILE', | ||
| 258 | --- | ||
| 259 | title: Contact | ||
| 260 | description: Hearth & Crumb's address, phone number, email and opening hours. | ||
| 261 | template: true | ||
| 262 | --- | ||
| 263 | [% b = site.data.business %] | ||
| 264 | <div class="prose"> | ||
| 265 | <h1>Find us</h1> | ||
| 266 | <p> | ||
| 267 | [% b.address.street | html %], [% b.address.city | html %]<br> | ||
| 268 | <a href="[% b.map %]">Open in a map</a> | ||
| 269 | </p> | ||
| 270 | <p>Call <a href="tel:[% b.phone | html %]">[% b.phone | html %]</a> or email | ||
| 271 | <a href="mailto:[% b.email | html %]">[% b.email | html %]</a>. For special orders, | ||
| 272 | please give us three days' notice.</p> | ||
| 273 | </div> | ||
| 274 | FILE | ||
| 275 | |||
| 276 | '_source/news.html' => <<'FILE', | ||
| 277 | --- | ||
| 278 | title: News | ||
| 279 | description: News from Hearth & Crumb Bakery. | ||
| 280 | template: true | ||
| 281 | paginate: | ||
| 282 | category: news | ||
| 283 | per_page: 10 | ||
| 284 | --- | ||
| 285 | <div class="prose"> | ||
| 286 | <h1>News</h1> | ||
| 287 | [% FOR post IN paginator.items %] | ||
| 288 | <article> | ||
| 289 | <h2><a href="[% post.url %]">[% post.title | html %]</a></h2> | ||
| 290 | <p class="meta">[% post.date.strftime('%d %B %Y') %]</p> | ||
| 291 | [% post.excerpt %] | ||
| 292 | </article> | ||
| 293 | [% END %] | ||
| 294 | [% IF paginator.next_url %]<p><a href="[% paginator.next_url %]">Older news</a></p>[% END %] | ||
| 295 | </div> | ||
| 296 | FILE | ||
| 297 | |||
| 298 | '_source/news/_schema.yml' => <<'FILE', | ||
| 299 | # Every news post must have these. Run "dapper check" to see any problems. | ||
| 300 | required: [title, date, categories, description] | ||
| 301 | fields: | ||
| 302 | title: | ||
| 303 | type: string | ||
| 304 | max_length: 90 | ||
| 305 | date: | ||
| 306 | type: date | ||
| 307 | categories: | ||
| 308 | type: list | ||
| 309 | values: [news] | ||
| 310 | description: | ||
| 311 | type: string | ||
| 312 | max_length: 200 | ||
| 313 | FILE | ||
| 314 | |||
| 315 | '_source/news/now-open-sundays.md' => <<'FILE', | ||
| 316 | --- | ||
| 317 | title: Now Open on Sundays | ||
| 318 | layout: post | ||
| 319 | categories: news | ||
| 320 | date: 2026-02-01 | ||
| 321 | description: Starting in February, Hearth & Crumb is open on Sundays from 8am to 2pm. | ||
| 322 | --- | ||
| 323 | |||
| 324 | Good news for weekend mornings: starting in February, we're open on Sundays | ||
| 325 | from 8am to 2pm, with the full bread and pastry lineup. | ||
| 326 | FILE | ||
| 327 | |||
| 328 | 'images/storefront.svg' => <<'FILE', | ||
| 329 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600" role="img" aria-label="Placeholder image of a storefront"><rect width="1200" height="600" fill="#f4e9dc"/><rect x="200" y="140" width="800" height="400" rx="8" fill="#8a4b2a"/><rect x="260" y="230" width="320" height="250" fill="#fbe3c0"/><rect x="640" y="230" width="300" height="310" fill="#5c2f1a"/><circle cx="340" cy="420" r="38" fill="#c98a4b"/><circle cx="430" cy="420" r="38" fill="#b87538"/><circle cx="520" cy="420" r="38" fill="#c98a4b"/><text x="600" y="200" font-family="Georgia, serif" font-size="44" text-anchor="middle" fill="#fbe3c0">Hearth & Crumb</text></svg> | ||
| 330 | FILE | ||
| 331 | |||
| 332 | 'css/site.css' => <<'FILE', | ||
| 333 | :root { | ||
| 334 | --bg: #fffaf3; | ||
| 335 | --text: #2a1d16; | ||
| 336 | --muted: #6d5a4f; | ||
| 337 | --accent: #9c4a1f; | ||
| 338 | --accent-text: #ffffff; | ||
| 339 | --panel: #f4e9dc; | ||
| 340 | --notice: #ffe7a8; | ||
| 341 | } | ||
| 342 | @media (prefers-color-scheme: dark) { | ||
| 343 | :root { | ||
| 344 | --bg: #18120e; | ||
| 345 | --text: #f3e9df; | ||
| 346 | --muted: #c2ae9f; | ||
| 347 | --accent: #e89b6c; | ||
| 348 | --accent-text: #18120e; | ||
| 349 | --panel: #261c16; | ||
| 350 | --notice: #5a4513; | ||
| 351 | } | ||
| 352 | } | ||
| 353 | * { box-sizing: border-box; } | ||
| 354 | body { margin: 0; background: var(--bg); color: var(--text); font: 18px/1.6 Georgia, "Iowan Old Style", serif; } | ||
| 355 | h1, h2, h3, .site-name, nav, .button { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; } | ||
| 356 | a { color: var(--accent); } | ||
| 357 | a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; } | ||
| 358 | .skip { position: absolute; left: -999px; } | ||
| 359 | .skip:focus { left: 1rem; top: 1rem; background: var(--bg); padding: .5rem 1rem; } | ||
| 360 | .notice { margin: 0; padding: .6rem 1rem; text-align: center; background: var(--notice); font-family: sans-serif; } | ||
| 361 | .site-header, main, .site-footer { max-width: 68rem; margin: 0 auto; padding: 0 1.25rem; } | ||
| 362 | .site-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 1rem; padding-top: 1.5rem; padding-bottom: 1.5rem; } | ||
| 363 | .site-name { font-weight: 800; font-size: 1.3rem; color: var(--text); text-decoration: none; } | ||
| 364 | .site-header nav { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; } | ||
| 365 | .site-header nav a { color: var(--text); text-decoration: none; } | ||
| 366 | .site-header nav a:hover { color: var(--accent); } | ||
| 367 | .hero { display: grid; gap: 1.5rem; align-items: center; grid-template-columns: 3fr 2fr; margin-bottom: 3rem; } | ||
| 368 | .hero img { width: 100%; height: auto; border-radius: 14px; } | ||
| 369 | .hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.15; margin: 0 0 1rem; } | ||
| 370 | @media (max-width: 720px) { .hero { grid-template-columns: 1fr; } } | ||
| 371 | .button { display: inline-block; background: var(--accent); color: var(--accent-text); padding: .65rem 1.3rem; border-radius: 999px; text-decoration: none; font-weight: 700; } | ||
| 372 | .services { list-style: none; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); } | ||
| 373 | .services li { background: var(--panel); border-radius: 12px; padding: 1rem 1.25rem; } | ||
| 374 | .services h3 { margin: 0 0 .25rem; } | ||
| 375 | .services p { margin: 0; color: var(--muted); } | ||
| 376 | .prose { max-width: 42rem; } | ||
| 377 | .meta { color: var(--muted); font-size: .9em; } | ||
| 378 | .site-footer { margin-top: 4rem; padding-top: 2rem; padding-bottom: 2rem; border-top: 2px solid var(--panel); display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); } | ||
| 379 | .site-footer h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); } | ||
| 380 | .hours { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; margin: 0; } | ||
| 381 | .hours dt { font-weight: 600; } | ||
| 382 | .hours dd { margin: 0; white-space: nowrap; } | ||
| 383 | address { font-style: normal; } | ||
| 384 | .copyright { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; margin: 0; } | ||
| 385 | FILE | ||
| 386 | }; | ||
| 387 | } | ||
| 388 | |||
| 389 | 32 | 1; | |