@profullstack/footer 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @profullstack/footer
2
2
 
3
3
  One footer for every Profullstack site: your links, the copyright line, and the
4
- `<< Profullstack >> ⚄` webring nav (previous, ring, next, random).
4
+ `<< Profullstack >>` webring nav (previous, ring, next).
5
5
 
6
6
  **Publish once, every site updates.** The markup and CSS ship as data
7
7
  (`template.json`). At render time each site fetches
@@ -72,6 +72,7 @@ npx @profullstack/footer html --site https://example.com/ --link Docs=/docs
72
72
  | `ring` | `{ slug: 'profullstack', name: 'Profullstack', host: 'https://rssamplifier.com' }` | |
73
73
  | `css` | `true` | `false` drops the `<style>`; style `.pfs-footer*` yourself |
74
74
  | `houseLinks` | `true` | `false` hides links the template adds for every site |
75
+ | `nonce` | | CSP nonce for the inline `<style>`; or `css: false` and style `.pfs-footer*` yourself |
75
76
 
76
77
  Theme it with `--pfs-footer-muted`, `--pfs-footer-gap` and `--pfs-footer-size` on
77
78
  `.pfs-footer`; colors otherwise inherit from the page.
@@ -83,7 +83,7 @@ switch (cmd) {
83
83
  const html = (await res.text()).replace(/&amp;/g, '&');
84
84
  const want = ringLinks(home);
85
85
  let ok = res.ok;
86
- for (const k of /** @type {const} */ (['previous', 'next', 'random'])) {
86
+ for (const k of /** @type {const} */ (['previous', 'next'])) {
87
87
  const has = html.includes(want[k]);
88
88
  ok &&= has;
89
89
  process.stdout.write(`${has ? 'ok ' : 'MISS'} ${k} ${want[k]}\n`);
package/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export interface FooterOptions {
18
18
  css?: boolean;
19
19
  /** false hides the template's house links. */
20
20
  houseLinks?: boolean;
21
+ /** CSP nonce for the inline <style> (style-src 'nonce-...'). */
22
+ nonce?: string;
21
23
  }
22
24
  export interface FooterTemplate {
23
25
  version: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/footer",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "One footer for every Profullstack site: links, copyright and the << Profullstack >> webring nav with Random. Sites render the @latest template from the CDN at runtime, so a release updates every site without a redeploy.",
6
6
  "keywords": ["footer", "webring", "openwebring", "copyright", "react", "nextjs", "hono", "ssr"],
package/src/render.js CHANGED
@@ -109,6 +109,7 @@ export function fill(tpl, vars) {
109
109
  * ring?: { slug?: string, name?: string, host?: string },
110
110
  * css?: boolean,
111
111
  * houseLinks?: boolean,
112
+ * nonce?: string,
112
113
  * }} FooterOptions
113
114
  * @typedef {{ version: string, renderer: number, css: string, link: string, footer: string, houseLinks?: FooterLink[] }} FooterTemplate
114
115
  */
@@ -141,6 +142,7 @@ export function renderFooter(template, opts) {
141
142
  tagline: opts.tagline ?? '',
142
143
  site: canonicalSite(opts.site),
143
144
  name: opts.name ?? '',
145
+ nonce: opts.nonce ?? '',
144
146
  });
145
147
  }
146
148
 
package/src/template.js CHANGED
@@ -8,20 +8,8 @@
8
8
  // Bump `renderer` only when the template needs placeholders an older
9
9
  // render.js does not fill; older installs then keep their bundled template.
10
10
 
11
- // OpenIcon line glyphs (github.com/profullstack/openicon, keys `random` and
12
- // `vote`) as CSS masks. A template may not carry <svg> (sanitizeTemplate strips
13
- // it), and a mask over currentColor keeps the icon the colour of the link.
14
- const glyph = (body) =>
15
- `url("data:image/svg+xml,${encodeURIComponent(
16
- `<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'>${body}</svg>`,
17
- )}")`;
18
- const RANDOM = glyph(
19
- "<rect x='3' y='3' width='18' height='18' rx='3'/><circle cx='8' cy='8' r='1'/><circle cx='16' cy='8' r='1'/><circle cx='12' cy='12' r='1'/><circle cx='8' cy='16' r='1'/><circle cx='16' cy='16' r='1'/>",
20
- );
21
- const VOTE = glyph("<path d='M12 4 21 19H3z'/>");
22
-
23
11
  export default {
24
- version: '0.2.0',
12
+ version: '0.2.2',
25
13
  renderer: 1,
26
14
  css: [
27
15
  '.pfs-footer{--pfs-footer-muted:color-mix(in srgb,currentColor 62%,transparent);--pfs-footer-gap:.5rem 1.25rem;--pfs-footer-size:.875rem;',
@@ -31,29 +19,19 @@ export default {
31
19
  '.pfs-footer a:hover,.pfs-footer a:focus-visible{color:inherit;text-decoration:underline}',
32
20
  '.pfs-footer__links{display:flex;flex-wrap:wrap;justify-content:center;gap:var(--pfs-footer-gap)}',
33
21
  '.pfs-footer__ring{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:.6rem}',
34
- '.pfs-footer__icon{display:inline-block;width:1em;height:1em;vertical-align:-.125em;background-color:currentColor;',
35
- '-webkit-mask:var(--pfs-footer-glyph) center/contain no-repeat;mask:var(--pfs-footer-glyph) center/contain no-repeat}',
36
- `.pfs-footer__icon--random{--pfs-footer-glyph:${RANDOM}}`,
37
- `.pfs-footer__icon--vote{--pfs-footer-glyph:${VOTE}}`,
38
22
  '.pfs-footer__copy{margin:0;color:var(--pfs-footer-muted)}',
39
23
  '.pfs-footer__copy a{color:inherit}',
40
24
  ].join(''),
41
25
  link: '<a href="{{href}}"{{#rel}} rel="{{rel}}"{{/rel}}>{{label}}</a>',
42
26
  footer: [
43
27
  '<footer class="pfs-footer" data-pfs-footer="{{version}}">',
44
- '{{#css}}<style>{{{css}}}</style>{{/css}}',
28
+ '{{#css}}<style{{#nonce}} nonce="{{nonce}}"{{/nonce}}>{{{css}}}</style>{{/css}}',
45
29
  '<div class="pfs-footer__inner">',
46
30
  '{{#links}}<nav class="pfs-footer__links" aria-label="Footer">{{{links}}}</nav>{{/links}}',
47
31
  '<nav class="webring pfs-footer__ring" aria-label="{{ring_name}} webring">',
48
32
  '<a href="{{previous}}" rel="prev" title="Previous site">&lt;&lt;</a>',
49
33
  '<a href="{{ring}}">{{ring_name}}</a>',
50
34
  '<a href="{{next}}" rel="next" title="Next site">&gt;&gt;</a>',
51
- '<a href="{{random}}" title="Random site" aria-label="Random site"><span class="pfs-footer__icon pfs-footer__icon--random" aria-hidden="true"></span></a>',
52
- // Anonymous, throttled vote for this site. A bare URL because a new
53
- // placeholder would need a renderer bump; the ring host finds the site
54
- // from the Referer, and referrerpolicy keeps the origin on sites whose
55
- // own policy is no-referrer.
56
- '<a href="{{ring}}/vote" referrerpolicy="origin" title="Vote for this site" aria-label="Vote for this site"><span class="pfs-footer__icon pfs-footer__icon--vote" aria-hidden="true"></span></a>',
57
35
  '</nav>',
58
36
  '<p class="pfs-footer__copy">&copy; {{years}} <a href="{{owner_url}}">{{owner_name}}</a>{{#tagline}} &middot; {{tagline}}{{/tagline}}</p>',
59
37
  '</div>',
package/template.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "version": "0.2.0",
2
+ "version": "0.2.2",
3
3
  "renderer": 1,
4
- "css": ".pfs-footer{--pfs-footer-muted:color-mix(in srgb,currentColor 62%,transparent);--pfs-footer-gap:.5rem 1.25rem;--pfs-footer-size:.875rem;border-top:1px solid color-mix(in srgb,currentColor 14%,transparent);font-size:var(--pfs-footer-size);line-height:1.5;color:inherit}.pfs-footer__inner{max-width:72rem;margin:0 auto;padding:1.5rem 1rem;display:flex;flex-direction:column;align-items:center;gap:.75rem;text-align:center}.pfs-footer a{color:var(--pfs-footer-muted);text-decoration:none}.pfs-footer a:hover,.pfs-footer a:focus-visible{color:inherit;text-decoration:underline}.pfs-footer__links{display:flex;flex-wrap:wrap;justify-content:center;gap:var(--pfs-footer-gap)}.pfs-footer__ring{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:.6rem}.pfs-footer__icon{display:inline-block;width:1em;height:1em;vertical-align:-.125em;background-color:currentColor;-webkit-mask:var(--pfs-footer-glyph) center/contain no-repeat;mask:var(--pfs-footer-glyph) center/contain no-repeat}.pfs-footer__icon--random{--pfs-footer-glyph:url(\"data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2024%2024'%20fill%3D'none'%20stroke%3D'black'%20stroke-width%3D'2'%20stroke-linecap%3D'round'%20stroke-linejoin%3D'round'%3E%3Crect%20x%3D'3'%20y%3D'3'%20width%3D'18'%20height%3D'18'%20rx%3D'3'%2F%3E%3Ccircle%20cx%3D'8'%20cy%3D'8'%20r%3D'1'%2F%3E%3Ccircle%20cx%3D'16'%20cy%3D'8'%20r%3D'1'%2F%3E%3Ccircle%20cx%3D'12'%20cy%3D'12'%20r%3D'1'%2F%3E%3Ccircle%20cx%3D'8'%20cy%3D'16'%20r%3D'1'%2F%3E%3Ccircle%20cx%3D'16'%20cy%3D'16'%20r%3D'1'%2F%3E%3C%2Fsvg%3E\")}.pfs-footer__icon--vote{--pfs-footer-glyph:url(\"data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2024%2024'%20fill%3D'none'%20stroke%3D'black'%20stroke-width%3D'2'%20stroke-linecap%3D'round'%20stroke-linejoin%3D'round'%3E%3Cpath%20d%3D'M12%204%2021%2019H3z'%2F%3E%3C%2Fsvg%3E\")}.pfs-footer__copy{margin:0;color:var(--pfs-footer-muted)}.pfs-footer__copy a{color:inherit}",
4
+ "css": ".pfs-footer{--pfs-footer-muted:color-mix(in srgb,currentColor 62%,transparent);--pfs-footer-gap:.5rem 1.25rem;--pfs-footer-size:.875rem;border-top:1px solid color-mix(in srgb,currentColor 14%,transparent);font-size:var(--pfs-footer-size);line-height:1.5;color:inherit}.pfs-footer__inner{max-width:72rem;margin:0 auto;padding:1.5rem 1rem;display:flex;flex-direction:column;align-items:center;gap:.75rem;text-align:center}.pfs-footer a{color:var(--pfs-footer-muted);text-decoration:none}.pfs-footer a:hover,.pfs-footer a:focus-visible{color:inherit;text-decoration:underline}.pfs-footer__links{display:flex;flex-wrap:wrap;justify-content:center;gap:var(--pfs-footer-gap)}.pfs-footer__ring{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:.6rem}.pfs-footer__copy{margin:0;color:var(--pfs-footer-muted)}.pfs-footer__copy a{color:inherit}",
5
5
  "link": "<a href=\"{{href}}\"{{#rel}} rel=\"{{rel}}\"{{/rel}}>{{label}}</a>",
6
- "footer": "<footer class=\"pfs-footer\" data-pfs-footer=\"{{version}}\">{{#css}}<style>{{{css}}}</style>{{/css}}<div class=\"pfs-footer__inner\">{{#links}}<nav class=\"pfs-footer__links\" aria-label=\"Footer\">{{{links}}}</nav>{{/links}}<nav class=\"webring pfs-footer__ring\" aria-label=\"{{ring_name}} webring\"><a href=\"{{previous}}\" rel=\"prev\" title=\"Previous site\">&lt;&lt;</a><a href=\"{{ring}}\">{{ring_name}}</a><a href=\"{{next}}\" rel=\"next\" title=\"Next site\">&gt;&gt;</a><a href=\"{{random}}\" title=\"Random site\" aria-label=\"Random site\"><span class=\"pfs-footer__icon pfs-footer__icon--random\" aria-hidden=\"true\"></span></a><a href=\"{{ring}}/vote\" referrerpolicy=\"origin\" title=\"Vote for this site\" aria-label=\"Vote for this site\"><span class=\"pfs-footer__icon pfs-footer__icon--vote\" aria-hidden=\"true\"></span></a></nav><p class=\"pfs-footer__copy\">&copy; {{years}} <a href=\"{{owner_url}}\">{{owner_name}}</a>{{#tagline}} &middot; {{tagline}}{{/tagline}}</p></div></footer>",
6
+ "footer": "<footer class=\"pfs-footer\" data-pfs-footer=\"{{version}}\">{{#css}}<style{{#nonce}} nonce=\"{{nonce}}\"{{/nonce}}>{{{css}}}</style>{{/css}}<div class=\"pfs-footer__inner\">{{#links}}<nav class=\"pfs-footer__links\" aria-label=\"Footer\">{{{links}}}</nav>{{/links}}<nav class=\"webring pfs-footer__ring\" aria-label=\"{{ring_name}} webring\"><a href=\"{{previous}}\" rel=\"prev\" title=\"Previous site\">&lt;&lt;</a><a href=\"{{ring}}\">{{ring_name}}</a><a href=\"{{next}}\" rel=\"next\" title=\"Next site\">&gt;&gt;</a></nav><p class=\"pfs-footer__copy\">&copy; {{years}} <a href=\"{{owner_url}}\">{{owner_name}}</a>{{#tagline}} &middot; {{tagline}}{{/tagline}}</p></div></footer>",
7
7
  "houseLinks": []
8
8
  }