Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/article-list-setting-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/theme-check-common': minor
'@shopify/theme-language-server-common': minor
---

Add support for `article_list` theme settings and infer their values as arrays of articles.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('ValidBlockContentSettingType', () => {
['checkbox', 'boolean'],
['product', 'product'],
['product_list', 'product[]'],
['article_list', 'article[]'],
])('reports a %s schema setting named content on its type', async (settingType, liquidType) => {
const source = blockSource([{ id: 'content', type: settingType }]);

Expand Down
1 change: 1 addition & 0 deletions packages/theme-check-common/src/schema-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('schemaSettingLiquidType', () => {
['video', 'video'],
['collection_list', 'collection[]'],
['product_list', 'product[]'],
['article_list', 'article[]'],
] as const)('maps %s settings to their Liquid type', (type, expected) => {
expect(schemaSettingLiquidType(type)).toBe(expected);
});
Expand Down
2 changes: 2 additions & 0 deletions packages/theme-check-common/src/schema-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export function schemaSettingLiquidType(settingType: string): string | undefined
return 'collection[]';
case 'product_list':
return 'product[]';
case 'article_list':
return 'article[]';
default:
return undefined;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/theme-check-common/src/types/schemas/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export declare namespace Setting {
| Product
| CollectionList
| ProductList
| ArticleList
| MetaobjectList
| Text
| Textarea
Expand Down Expand Up @@ -57,6 +58,7 @@ export declare namespace Setting {
// Resource List Settings
CollectionList = 'collection_list',
ProductList = 'product_list',
ArticleList = 'article_list',
MetaobjectList = 'metaobject_list',

// Text Settings
Expand Down Expand Up @@ -140,6 +142,7 @@ export declare namespace Setting {

export interface CollectionList extends ResourceList<Type.CollectionList> {}
export interface ProductList extends ResourceList<Type.ProductList> {}
export interface ArticleList extends ResourceList<Type.ArticleList> {}
export interface MetaobjectList extends ResourceList<Type.MetaobjectList> {
metaobject_type: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ describe('Module: TypeSystem', () => {
}
});

it('should support section settings in section files', async () => {
it('should support article_list section settings in section files', async () => {
const sourceCode = `
{{ section.settings.my_list }}
{% schema %}
Expand All @@ -400,7 +400,7 @@ describe('Module: TypeSystem', () => {
{
"id": "my_list",
"label": "t:my-setting.label",
"type": "product_list"
"type": "article_list"
}
]
}
Expand All @@ -414,7 +414,7 @@ describe('Module: TypeSystem', () => {
ast,
'file:///sections/my-section.liquid',
);
expect(inferredType).to.eql({ kind: 'array', valueType: 'product' } as ArrayType);
expect(inferredType).to.eql({ kind: 'array', valueType: 'article' } as ArrayType);
});

it.each([
Expand Down Expand Up @@ -447,6 +447,7 @@ describe('Module: TypeSystem', () => {
['video', 'video'],
['collection_list', { kind: 'array', valueType: 'collection' }],
['product_list', { kind: 'array', valueType: 'product' }],
['article_list', { kind: 'array', valueType: 'article' }],
] as const)('infers block.settings values for %s settings', async (settingType, expectedType) => {
const sourceCode = `
{{ block.settings.value }}
Expand Down
Loading