Skip to content

Commit

Permalink
Add file_key and file_url to FigmaFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Würthner committed Nov 1, 2024
1 parent 395d682 commit bf93c5f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ Hint: You can also use Jinja filters to modify the name, e.g. `{{ color.name|low
- `file`: The Figma file name
- `last_modified`: Last modified date of the Figma file
- `version`: The version of the Figma file
- `file_key`: The file key from config
- `file_url`: The URL of the file to open in the browser

#### Scale
- `scale`: The scale as floating point number as configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class FigmaApi(
onDownload { bytesSentTotal, contentLength ->
status("Loading file $fileKey (${bytesSentTotal / 1024}KiB)")
}
}.body()
}.body<FigmaFile>().copy(
fileKey = fileKey
)

internal suspend fun loadVariable(
references: List<FigmaVariableReference.WithPath>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ data class FigmaFile internal constructor(
internal val name: String,
internal val lastModified: String,
internal val version: String,
internal val fileKey: String? = null,
) : Contextable {
override fun toContext() = mapOf(
"file" to name,
"last_modified" to lastModified,
"version" to version,
"file_key" to (fileKey ?: ""),
"file_url" to "https://www.figma.com/design/$fileKey",
)
}
1 change: 1 addition & 0 deletions samples/android_values.xml.figex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<!-- This file was generated using FigEx at {{ date }} -->
<!-- Source File: {{ figma.file }} -->
<!-- Source URL: {{ figma.file_url }} -->
<!-- Source last modified: {{ figma.last_modified }} -->
<!-- Source version: {{ figma.version }} -->
<!-- Template var demo: {{ templateVarDemo }} -->
Expand Down

0 comments on commit bf93c5f

Please sign in to comment.