Skip to content

Deeplink to open a theme block by its type value specified in the liquid schema #631

Open
@albchu

Description

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.
It would be good DX to allow theme developers to deeplink through theme block type in blocks and preset nested blocks

Describe the solution you'd like
A clear and concise description of what you want to happen.
Deeplink click to open the corresponding theme block asset

Checklist

  • I have checked and made sure that the proposal adheres to this plugin's principles

Additional context
Add any other context or screenshots about the feature request here.
Something like this

// {% schema %}{ "blocks": [{ "type": "█" }] }{% endschema %}
LiquidRawTag(node) {
  if (node.name !== 'schema') return;
  if (!schema || isError(schema.ast) || isError(schema.validSchema)) return;
  const offset = node.blockPositionStart.end;
  const blockDefs = schema.validSchema.blocks;
  if (!blockDefs || hasLocalBlocks(blockDefs)) return;
  return blockDefs.map((def, i) => {
    const type = def.type;
    const typeNode = nodeAtPath(schema.ast, [blocks, i, "type"]);
    return DocumentLink.create(
      Range.create(offset + locStart(typeNode), offset + locEnd(typeNode)),
      Utils.resolvePath(root, 'blocks', type + ".liquid").toString(),
    );
  });
}

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions