code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

feat: support component, variant and links for raw file

Open amoshydra opened this issue 11 months ago • 0 comments

Preface:

I have read the contributing guidelines

However, we are currently not accepting any PRs at this time.

Understood if the PR will be closed. I am creating this PR to share a code reference that supports the feature request highlighted in #262.

Summary

This PR will allow additional CodeConnectJSON attribute to be defined via frontmatter syntax in the raw file.

Currently it is limited to the following properties only:

  • url
  • component
  • variant
  • links

This PR will add yaml as a dependency

Usage

/*---
url: https://www.figma.com/file/your-file-id/Component?node-id=123
component: Button
variant:
  type: primary,
  has outline: true
links:
  - name: Awesome Document
    url: https://example.com
---*/

const figma = require('figma')
const instance = figma.selectedInstance

Frontmatter is wrapped in comment block

Syntax highlighting in VS Code will not work correctly out of the box with the original suggested usage in #262

image

After wrapping in a comment block (changed in https://github.com/figma/code-connect/compare/8e2607ac42afbf6a47c86cc64310afb86872e752..b0088e339e6e613c65bbe3f5bbbc6aad7df534ef)

image


close #262

amoshydra avatar Mar 15 '25 16:03 amoshydra