Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
albchu opened this issue Dec 2, 2024 · 0 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@albchu
Copy link
Contributor

albchu commented Dec 2, 2024

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(),
    );
  });
}
@itsjustriley itsjustriley self-assigned this Dec 2, 2024
@graygilmore graygilmore added the enhancement New feature or request label Dec 2, 2024
@itsjustriley itsjustriley removed their assignment Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants