@rocket/js 0.2.1 → 0.3.0

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.
Files changed (55) hide show
  1. package/dist-types/exports/adapters/cloudflare.d.ts +2 -0
  2. package/dist-types/exports/adapters/cloudflare.d.ts.map +1 -0
  3. package/dist-types/exports/types/rocket.d.ts +11 -0
  4. package/dist-types/exports/types/rocket.d.ts.map +1 -1
  5. package/dist-types/exports/types.d.ts +1 -1
  6. package/dist-types/exports/types.d.ts.map +1 -1
  7. package/dist-types/src/PageData.d.ts +9 -0
  8. package/dist-types/src/PageData.d.ts.map +1 -1
  9. package/dist-types/src/RocketCodeBlock.d.ts.map +1 -1
  10. package/dist-types/src/RocketJsDemo.d.ts.map +1 -1
  11. package/dist-types/src/adapters/cloudflare.d.ts +27 -0
  12. package/dist-types/src/adapters/cloudflare.d.ts.map +1 -0
  13. package/dist-types/src/adapters/netlify.d.ts.map +1 -1
  14. package/dist-types/src/adapters/redirects.d.ts +14 -0
  15. package/dist-types/src/adapters/redirects.d.ts.map +1 -0
  16. package/dist-types/src/icons.d.ts +27 -0
  17. package/dist-types/src/icons.d.ts.map +1 -1
  18. package/dist-types/src/layouts/atlas/atlasBlogLayout.d.ts.map +1 -1
  19. package/dist-types/src/layouts/atlas/atlasDocLayout.d.ts.map +1 -1
  20. package/dist-types/src/layouts/atlas/atlasHeroLayout.d.ts.map +1 -1
  21. package/dist-types/src/layouts/atlas/atlasNotFoundLayout.d.ts.map +1 -1
  22. package/dist-types/src/layouts/layout-helper.d.ts.map +1 -1
  23. package/dist-types/src/markdownHook.d.ts.map +1 -1
  24. package/dist-types/src/menus/MainMenu.d.ts.map +1 -1
  25. package/dist-types/src/menus/RocketMenu.d.ts.map +1 -1
  26. package/dist-types/src/menus/RocketToc.d.ts.map +1 -1
  27. package/dist-types/src/menus/pageNavigation.d.ts.map +1 -1
  28. package/dist-types/src/publicAssets.d.ts.map +1 -1
  29. package/exports/adapters/cloudflare.js +1 -0
  30. package/exports/types/rocket.ts +17 -4
  31. package/exports/types.ts +1 -0
  32. package/package.json +40 -26
  33. package/src/PageData.js +15 -0
  34. package/src/RocketCodeBlock.js +11 -9
  35. package/src/RocketJsDemo.js +7 -5
  36. package/src/adapters/cloudflare.js +522 -0
  37. package/src/adapters/netlify.js +2 -24
  38. package/src/adapters/redirects.js +31 -0
  39. package/src/cli/RocketBuild.js +5 -2
  40. package/src/config.js +1 -1
  41. package/src/icons.js +138 -0
  42. package/src/layouts/atlas/atlasBlogLayout.js +45 -31
  43. package/src/layouts/atlas/atlasDocLayout.js +22 -16
  44. package/src/layouts/atlas/atlasHeroLayout.js +39 -31
  45. package/src/layouts/atlas/atlasNotFoundLayout.js +5 -3
  46. package/src/layouts/layout-helper.js +38 -26
  47. package/src/main.js +15 -0
  48. package/src/markdownCompiler.js +5 -1
  49. package/src/menus/MainMenu.js +17 -13
  50. package/src/menus/RocketMenu.js +25 -19
  51. package/src/menus/RocketToc.js +7 -5
  52. package/src/menus/pageNavigation.js +24 -10
  53. package/src/publicAssets.js +9 -2
  54. package/src/transform.js +7 -1
  55. package/src/wds-plugin.js +2 -1
@@ -47,25 +47,31 @@ export class RocketMenu extends LitElement {
47
47
 
48
48
  return html`
49
49
  <li class=${classMap(itemClasses)}>
50
- ${page.menuNoLink
51
- ? html`<span class=${classMap(classes)}>${title}</span>`
52
- : html`<a
53
- href=${ifDefined(page.url)}
54
- class=${classMap(classes)}
55
- aria-current=${ifDefined(isCurrent ? 'page' : undefined)}
56
- >${page.iconName
57
- ? html`<rocket-icon
58
- class="nav-icon"
59
- name=${page.iconName}
60
- aria-hidden="true"
61
- ></rocket-icon>`
62
- : ''}<span class="nav-text">${title}</span></a
63
- >`}
64
- ${page.children.length > 0
65
- ? html`<ul>
66
- ${page.children.map(child => this.list(child, depth + 1))}
67
- </ul>`
68
- : ''}
50
+ ${
51
+ page.menuNoLink
52
+ ? html`<span class=${classMap(classes)}>${title}</span>`
53
+ : html`<a
54
+ href=${ifDefined(page.url)}
55
+ class=${classMap(classes)}
56
+ aria-current=${ifDefined(isCurrent ? 'page' : undefined)}
57
+ >${
58
+ page.iconName
59
+ ? html`<rocket-icon
60
+ class="nav-icon"
61
+ name=${page.iconName}
62
+ aria-hidden="true"
63
+ ></rocket-icon>`
64
+ : ''
65
+ }<span class="nav-text">${title}</span></a
66
+ >`
67
+ }
68
+ ${
69
+ page.children.length > 0
70
+ ? html`<ul>
71
+ ${page.children.map(child => this.list(child, depth + 1))}
72
+ </ul>`
73
+ : ''
74
+ }
69
75
  </li>
70
76
  `;
71
77
  }
@@ -68,11 +68,13 @@ export class RocketToc extends LitElement {
68
68
  >
69
69
  ${headline.text}
70
70
  </a>
71
- ${headline.children.length > 0
72
- ? html`<ol>
73
- ${headline.children.map(child => this.list(child, depth + 1))}
74
- </ol>`
75
- : html``}
71
+ ${
72
+ headline.children.length > 0
73
+ ? html`<ol>
74
+ ${headline.children.map(child => this.list(child, depth + 1))}
75
+ </ol>`
76
+ : html``
77
+ }
76
78
  </li>
77
79
  `;
78
80
  }
@@ -50,20 +50,34 @@ export function renderPageNavigationCard(page, direction) {
50
50
  const isNext = direction === 'next';
51
51
  const label = isNext ? 'Next Page' : 'Previous Page';
52
52
  const icon = html`<span class="page-card-icon" aria-hidden="true">
53
- ${isNext
54
- ? html`<svg class="page-card-arrow" viewBox="0 0 36 16" focusable="false" aria-hidden="true">
55
- <path d="M5 8h25m-7-6 7 6-7 6" />
56
- </svg>`
57
- : html`<svg class="page-card-arrow" viewBox="0 0 36 16" focusable="false" aria-hidden="true">
58
- <path d="M31 8H6m7-6-7 6 7 6" />
59
- </svg>`}
53
+ ${
54
+ isNext
55
+ ? html`<svg
56
+ class="page-card-arrow"
57
+ viewBox="0 0 36 16"
58
+ focusable="false"
59
+ aria-hidden="true"
60
+ >
61
+ <path d="M5 8h25m-7-6 7 6-7 6" />
62
+ </svg>`
63
+ : html`<svg
64
+ class="page-card-arrow"
65
+ viewBox="0 0 36 16"
66
+ focusable="false"
67
+ aria-hidden="true"
68
+ >
69
+ <path d="M31 8H6m7-6-7 6 7 6" />
70
+ </svg>`
71
+ }
60
72
  </span>`;
61
73
  const text = html`<span class="page-card-text">
62
74
  <span class="page-card-label">${label}</span>
63
75
  <strong class="page-card-title">${page.linkText}</strong>
64
- ${page.sectionLabel
65
- ? html`<span class="page-card-section">${page.sectionLabel}</span>`
66
- : nothing}
76
+ ${
77
+ page.sectionLabel
78
+ ? html`<span class="page-card-section">${page.sectionLabel}</span>`
79
+ : nothing
80
+ }
67
81
  </span>`;
68
82
 
69
83
  return html`<a
@@ -5,6 +5,12 @@ import { paginatedArchivePaths } from './page-pagination.js';
5
5
  import { normalizeDocumentPath, standaloneDemoPaths } from './standalone-demo-url.js';
6
6
  import { needsDefaultSocialPreviewImage, publicSocialPreviewPages } from './socialPreviewImages.js';
7
7
 
8
+ /** Adapters that write `_redirects` into the build output, by adapter name. */
9
+ const REDIRECTS_FILE_HOSTS = new Map([
10
+ ['netlify', 'Netlify'],
11
+ ['cloudflare', 'Cloudflare'],
12
+ ]);
13
+
8
14
  export const PUBLIC_ASSETS_DIR = 'public';
9
15
 
10
16
  /**
@@ -237,8 +243,9 @@ function generatedOutputClaims({ pages, generatedPages, config, emitRedirectFall
237
243
  if (config.siteDiscoverability?.robots === true) {
238
244
  claims.set('/robots.txt', 'generated Robots File');
239
245
  }
240
- if (config.adapter?.name === 'netlify' && config.urlLifecycle?.redirects?.length) {
241
- claims.set('/_redirects', 'Netlify Redirect output');
246
+ const redirectsFileHost = REDIRECTS_FILE_HOSTS.get(config.adapter?.name ?? '');
247
+ if (redirectsFileHost && config.urlLifecycle?.redirects?.length) {
248
+ claims.set('/_redirects', `${redirectsFileHost} Redirect output`);
242
249
  }
243
250
 
244
251
  return claims;
package/src/transform.js CHANGED
@@ -412,7 +412,13 @@ export function isDemoCodeNode(node) {
412
412
  */
413
413
  function demoExportName(code) {
414
414
  const [, moduleExports] = parseExports(code);
415
- const name = moduleExports[0] && (moduleExports[0].ln || moduleExports[0].n);
415
+ const first = moduleExports[0];
416
+ const name =
417
+ first?.type === 'direct'
418
+ ? first.localName || first.name
419
+ : first?.type === 'reexport'
420
+ ? first.name
421
+ : undefined;
416
422
  if (!name) {
417
423
  throw new Error(
418
424
  'A ```js demo code block must export the demo function, ' +
package/src/wds-plugin.js CHANGED
@@ -129,7 +129,8 @@ export default (include, exclude, resolverPort, options = {}) => {
129
129
  type: rocketIconRuntime.type,
130
130
  };
131
131
  }
132
- const iconAsset = iconAssetStore.get(context.path);
132
+ const iconAsset =
133
+ iconAssetStore.get(context.path) ?? (await iconAssetStore.getWebAwesomeIcon(context.path));
133
134
  if (iconAsset) {
134
135
  return {
135
136
  body: iconAsset.svg,