-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Labels
Description
Describe the feature you'd like:
Currently parseReactDoc
is capable of returning variant
and link
to the CodeConnectJSON
code-connect/cli/src/react/parser.ts
Lines 910 to 911 in cfed2bf
const variant = variantArg ? parseVariant(variantArg, sourceFile, checker) : undefined | |
const links = linksArg ? parseLinks(linksArg, parserContext) : undefined |
It would be nice to also be able to specify variant
and link
in the Raw template.
code-connect/cli/src/commands/connect.ts
Lines 190 to 209 in cfed2bf
export function parseRawFile(filePath: string, label: string | undefined): CodeConnectJSON { | |
const fileContent = fs.readFileSync(filePath, 'utf-8') | |
const [firstLine, ...templateLines] = fileContent.split('\n') | |
const figmaNodeUrl = firstLine.replace(/\/\/\s*url=/, '').trim() | |
const template = templateLines.join('\n') | |
return { | |
figmaNode: figmaNodeUrl, | |
template, | |
// nestable by default unless user specifies otherwise | |
templateData: { nestable: true }, | |
language: 'raw', | |
label: label || 'Code', | |
source: '', | |
sourceLocation: { line: -1 }, | |
metadata: { | |
cliVersion: require('../../package.json').version, | |
}, | |
} | |
} |
Suggestion
Allow usage of frontmatter to specify more data for the CodeConnectJSON
---
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
it can be kept forward compatible too. yaml parsing can be enabled if the file starts with "---\n"
.
See POC in #263