@teleporthq/teleport-project-generator-next 0.44.13 → 0.44.14

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.
@@ -220,7 +220,11 @@ describe('the content-category-pages module', () => {
220
220
  helpPosts: async (params) => {
221
221
  calls.push(params)
222
222
  return [
223
- post({}),
223
+ post({
224
+ excerpt: 'Point your domain at the site',
225
+ content: '<p>Every step of connecting a domain</p>',
226
+ relatedPosts: [post({ id: 'p9' })],
227
+ }),
224
228
  post({ id: 'p2', slug: 'old', redirectUrl: '/help/connect-a-domain' }),
225
229
  post({ id: 'p3', slug: '' }),
226
230
  ]
@@ -243,6 +247,17 @@ describe('the content-category-pages module', () => {
243
247
  expect(page.posts.map((entry) => [entry.id, entry.href])).toEqual([
244
248
  ['p1', '/help/connect-a-domain'],
245
249
  ])
250
+ // A card, not a page: no body and none of the post's own lists.
251
+ expect(page.posts[0]).toMatchObject({
252
+ title: 'Connect a domain',
253
+ excerpt: 'Point your domain at the site',
254
+ content: '',
255
+ relatedPosts: [],
256
+ previousPosts: [],
257
+ nextPosts: [],
258
+ comments: [],
259
+ sections: [],
260
+ })
246
261
 
247
262
  // One read: the category's published posts, newest first, in the locale.
248
263
  expect(calls).toHaveLength(1)
@@ -1 +1 @@
1
- {"version":3,"file":"content-category-pages.d.ts","sourceRoot":"","sources":["../../../src/blog/content-category-pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAG1E,qHAAqH;AACrH,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAE3C,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,aAAa,CAAC,gBAAgB,CAAA;IACnC,QAAQ,EAAE,wBAAwB,CAAA;IAClC,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAA;IACrB,wGAAwG;IACxG,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,qGAAqG;AACrG,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,gBAAgB,EAAE,MAAM,CAGvE,CAAA;AAED,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,QAAS,cAAc,gBAAgB,KAAG,MACtE,CAAA;AAUf;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,kCAAkC,YACpC,0BAA0B,EAAE,KACpC,MAwJF,CAAA"}
1
+ {"version":3,"file":"content-category-pages.d.ts","sourceRoot":"","sources":["../../../src/blog/content-category-pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAG1E,qHAAqH;AACrH,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAE3C,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,aAAa,CAAC,gBAAgB,CAAA;IACnC,QAAQ,EAAE,wBAAwB,CAAA;IAClC,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAA;IACrB,wGAAwG;IACxG,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,qGAAqG;AACrG,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,gBAAgB,EAAE,MAAM,CAGvE,CAAA;AAED,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,QAAS,cAAc,gBAAgB,KAAG,MACtE,CAAA;AAUf;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,kCAAkC,YACpC,0BAA0B,EAAE,KACpC,MAuKF,CAAA"}
@@ -70,7 +70,7 @@ var generateContentCategoryPagesSource = function (presets) {
70
70
  "}",
71
71
  ].join('\n');
72
72
  });
73
- return "import { ".concat(treeImports.join(', '), ", localizeCategoryTree } from '@/blog-context'\n").concat(fetcherImports.join('\n'), "\n\n// The category pages' server-side reads. Generated from the content settings in the editor.\nvar PRESETS = {\n").concat(presetEntries.join('\n'), "\n}\nvar POST_LIMIT = ").concat(exports.CATEGORY_PAGE_POST_LIMIT, "\nvar CATEGORY_COLUMN = 'category_filter_ids'\nvar PUBLISHED_ONLY = { type: 'condition', source: 'status', destination: 'published', operand: '=' }\n// Public pages: the posts as a visitor is served them (published, no author\n// email), never as the store reads its own table.\nvar PAGE_READ = { as: 'visitor' }\n\n// A post field under its transformed name, else its column name.\nfunction field(post, key, column) {\n var value = post[key]\n return value === undefined || value === null || value === '' ? post[column] : value\n}\n\nfunction redirectsElsewhere(post) {\n var target = field(post, 'redirectUrl', 'redirect_url')\n return typeof target === 'string' && target.trim() !== ''\n}\n\n// Every category of the tree with the path of ancestors above it, top to bottom.\nfunction flattenTree(nodes, trail, out) {\n ;(nodes || []).forEach(function (node) {\n var path = trail.concat([node])\n out.push({ node: node, path: path })\n flattenTree(node.children, path, out)\n })\n return out\n}\n\nfunction categoryHref(config, category) {\n return config.categoryPath + '/' + encodeURIComponent(category.slug)\n}\n\nfunction postHref(config, post) {\n var key = field(post, config.postUrlKey, config.postUrlField)\n key = key === undefined || key === null ? '' : String(key).trim()\n return key ? config.postPath + '/' + encodeURIComponent(key) : null\n}\n\n// A category as a link: what the breadcrumbs and the subcategory cards show.\nfunction categorySummary(config, category) {\n return {\n id: category.id,\n name: category.name,\n slug: category.slug,\n description: category.description || '',\n icon: category.icon || null,\n imageUrl: category.imageUrl || null,\n href: categoryHref(config, category),\n childCount: (category.children || []).length,\n }\n}\n\n").concat(arranged_order_runtime_1.ARRANGED_ORDER_RUNTIME, "\n\nasync function resolveCategoryPage(preset, params) {\n var slug = params && params.slug !== undefined && params.slug !== null ? String(params.slug) : ''\n var locale = params && params.locale ? params.locale : null\n var tree = localizeCategoryTree(preset.tree, locale)\n var found = flattenTree(tree, [], []).filter(function (entry) {\n return entry.node.slug === slug\n })[0]\n if (!slug || !found) {\n return { data: null }\n }\n var category = found.node\n var rows = await preset.posts.fetchData({\n limit: POST_LIMIT,\n sortBy: 'created_at',\n sortOrder: 'desc',\n filters: JSON.stringify([\n PUBLISHED_ONLY,\n { type: 'condition', source: CATEGORY_COLUMN, destination: category.id, operand: 'array_overlap' },\n ]),\n locale: locale || undefined,\n }, PAGE_READ)\n var posts = []\n ;(Array.isArray(rows) ? rows : []).forEach(function (post) {\n if (!post || typeof post !== 'object' || redirectsElsewhere(post)) return\n var href = postHref(preset.config, post)\n if (href) posts.push(Object.assign({}, post, { href: href }))\n })\n if (preset.config.arranged) posts = arrangeCategoryPosts(posts, category)\n var summary = categorySummary(preset.config, category)\n return {\n data: Object.assign(summary, {\n breadcrumbs: found.path.slice(0, -1).map(function (ancestor) {\n return categorySummary(preset.config, ancestor)\n }),\n // Top category down to this one: what the sidebar layout highlights and opens.\n pathIds: found.path.map(function (node) {\n return node.id\n }),\n children: (category.children || []).map(function (child) {\n return categorySummary(preset.config, child)\n }),\n posts: posts,\n postCount: posts.length,\n }),\n }\n}\n\nasync function listCategoryPaths(preset) {\n return {\n data: flattenTree(preset.tree, [], []).map(function (entry) {\n return { slug: entry.node.slug }\n }),\n }\n}\n\n").concat(exportedFunctions.join('\n\n'), "\n");
73
+ return "import { ".concat(treeImports.join(', '), ", localizeCategoryTree } from '@/blog-context'\n").concat(fetcherImports.join('\n'), "\n\n// The category pages' server-side reads. Generated from the content settings in the editor.\nvar PRESETS = {\n").concat(presetEntries.join('\n'), "\n}\nvar POST_LIMIT = ").concat(exports.CATEGORY_PAGE_POST_LIMIT, "\nvar CATEGORY_COLUMN = 'category_filter_ids'\nvar PUBLISHED_ONLY = { type: 'condition', source: 'status', destination: 'published', operand: '=' }\n// Public pages: the posts as a visitor is served them (published, no author\n// email), never as the store reads its own table.\nvar PAGE_READ = { as: 'visitor' }\n\n// A post field under its transformed name, else its column name.\nfunction field(post, key, column) {\n var value = post[key]\n return value === undefined || value === null || value === '' ? post[column] : value\n}\n\nfunction redirectsElsewhere(post) {\n var target = field(post, 'redirectUrl', 'redirect_url')\n return typeof target === 'string' && target.trim() !== ''\n}\n\n// Every category of the tree with the path of ancestors above it, top to bottom.\nfunction flattenTree(nodes, trail, out) {\n ;(nodes || []).forEach(function (node) {\n var path = trail.concat([node])\n out.push({ node: node, path: path })\n flattenTree(node.children, path, out)\n })\n return out\n}\n\nfunction categoryHref(config, category) {\n return config.categoryPath + '/' + encodeURIComponent(category.slug)\n}\n\nfunction postHref(config, post) {\n var key = field(post, config.postUrlKey, config.postUrlField)\n key = key === undefined || key === null ? '' : String(key).trim()\n return key ? config.postPath + '/' + encodeURIComponent(key) : null\n}\n\n// A category as a link: what the breadcrumbs and the subcategory cards show.\nfunction categorySummary(config, category) {\n return {\n id: category.id,\n name: category.name,\n slug: category.slug,\n description: category.description || '',\n icon: category.icon || null,\n imageUrl: category.imageUrl || null,\n href: categoryHref(config, category),\n childCount: (category.children || []).length,\n }\n}\n\n").concat(arranged_order_runtime_1.ARRANGED_ORDER_RUNTIME, "\n\n// A category page lists cards: each post without its body or its own lists,\n// which no card shows (a 44-post category page carried 621 kB of data).\n// MUST mirror `card` in packages/renderer/src/utils/blog-posts.ts (teleport-gui).\nfunction postCard(post, href) {\n return Object.assign({}, post, {\n href: href,\n content: '',\n relatedPosts: [],\n previousPosts: [],\n nextPosts: [],\n comments: [],\n sections: [],\n })\n}\n\nasync function resolveCategoryPage(preset, params) {\n var slug = params && params.slug !== undefined && params.slug !== null ? String(params.slug) : ''\n var locale = params && params.locale ? params.locale : null\n var tree = localizeCategoryTree(preset.tree, locale)\n var found = flattenTree(tree, [], []).filter(function (entry) {\n return entry.node.slug === slug\n })[0]\n if (!slug || !found) {\n return { data: null }\n }\n var category = found.node\n var rows = await preset.posts.fetchData({\n limit: POST_LIMIT,\n sortBy: 'created_at',\n sortOrder: 'desc',\n filters: JSON.stringify([\n PUBLISHED_ONLY,\n { type: 'condition', source: CATEGORY_COLUMN, destination: category.id, operand: 'array_overlap' },\n ]),\n locale: locale || undefined,\n }, PAGE_READ)\n var posts = []\n ;(Array.isArray(rows) ? rows : []).forEach(function (post) {\n if (!post || typeof post !== 'object' || redirectsElsewhere(post)) return\n var href = postHref(preset.config, post)\n if (href) posts.push(postCard(post, href))\n })\n if (preset.config.arranged) posts = arrangeCategoryPosts(posts, category)\n var summary = categorySummary(preset.config, category)\n return {\n data: Object.assign(summary, {\n breadcrumbs: found.path.slice(0, -1).map(function (ancestor) {\n return categorySummary(preset.config, ancestor)\n }),\n // Top category down to this one: what the sidebar layout highlights and opens.\n pathIds: found.path.map(function (node) {\n return node.id\n }),\n children: (category.children || []).map(function (child) {\n return categorySummary(preset.config, child)\n }),\n posts: posts,\n postCount: posts.length,\n }),\n }\n}\n\nasync function listCategoryPaths(preset) {\n return {\n data: flattenTree(preset.tree, [], []).map(function (entry) {\n return { slug: entry.node.slug }\n }),\n }\n}\n\n").concat(exportedFunctions.join('\n\n'), "\n");
74
74
  };
75
75
  exports.generateContentCategoryPagesSource = generateContentCategoryPagesSource;
76
76
  /** `author_name` → `authorName`: the key the post transform exposes a column under. */
@@ -1 +1 @@
1
- {"version":3,"file":"content-category-pages.js","sourceRoot":"","sources":["../../../src/blog/content-category-pages.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,mEAAiE;AAEjE,qHAAqH;AACxG,QAAA,wBAAwB,GAAG,GAAG,CAAA;AAW3C,qGAAqG;AACxF,QAAA,YAAY,GAAmD;IAC1E,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;CAC3B,CAAA;AAED,uFAAuF;AAChF,IAAM,8BAA8B,GAAG,UAAC,GAAmC;IAChF,OAAA,UAAG,GAAG,UAAO;AAAb,CAAa,CAAA;AADF,QAAA,8BAA8B,kCAC5B;AAEf,IAAM,UAAU,GAAG,UAAC,IAAY;IAC9B,IAAM,OAAO,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACvD,IAAI,CAAC,OA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C3C,OAAA;YACE,gCAAyB,+BAAa,CAAC,+BAA+B,CACpE,MAAM,CAAC,GAAG,CACX,eAAY;YACb,+CAAwC,MAAM,CAAC,GAAG,cAAW;YAC7D,GAAG;YACH,EAAE;YACF,gCAAyB,+BAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,GAAG,CAAC,SAAM;YACvF,6CAAsC,MAAM,CAAC,GAAG,MAAG;YACnD,GAAG;SACJ,CAAC,IAAI,CAAC,IAAI,CAAC;IAVZ,CAUY,CACb,CAAA;IAED,OAAO,mBAAY,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,6DACzC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,gIAIzB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,mCAEP,gCAAwB,uyDAoDzC,+CAAsB,q8DAyDtB,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,OAC/B,CAAA;AACD,CAAC,CAAA;AA1JY,QAAA,kCAAkC,sCA0J9C;AAED,uFAAuF;AACvF,IAAM,WAAW,GAAG,UAAC,MAAc;IACjC,OAAA,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,UAAC,CAAC,EAAE,IAAY,IAAK,OAAA,IAAI,CAAC,WAAW,EAAE,EAAlB,CAAkB,CAAC;AAAvE,CAAuE,CAAA"}
1
+ {"version":3,"file":"content-category-pages.js","sourceRoot":"","sources":["../../../src/blog/content-category-pages.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,mEAAiE;AAEjE,qHAAqH;AACxG,QAAA,wBAAwB,GAAG,GAAG,CAAA;AAW3C,qGAAqG;AACxF,QAAA,YAAY,GAAmD;IAC1E,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;CAC3B,CAAA;AAED,uFAAuF;AAChF,IAAM,8BAA8B,GAAG,UAAC,GAAmC;IAChF,OAAA,UAAG,GAAG,UAAO;AAAb,CAAa,CAAA;AADF,QAAA,8BAA8B,kCAC5B;AAEf,IAAM,UAA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