From bf93c5f0b38a378c24d3bb01cc779b9aaa9d86fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20W=C3=BCrthner?= Date: Fri, 1 Nov 2024 10:29:37 +0100 Subject: [PATCH] Add file_key and file_url to FigmaFile --- README.md | 2 ++ .../src/main/kotlin/com/iodigital/figex/api/FigmaApi.kt | 4 +++- .../main/kotlin/com/iodigital/figex/models/figma/FigmaFile.kt | 3 +++ samples/android_values.xml.figex | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6df5031..391b7cf 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/figex-core/src/main/kotlin/com/iodigital/figex/api/FigmaApi.kt b/figex-core/src/main/kotlin/com/iodigital/figex/api/FigmaApi.kt index 1c74e2e..370740b 100644 --- a/figex-core/src/main/kotlin/com/iodigital/figex/api/FigmaApi.kt +++ b/figex-core/src/main/kotlin/com/iodigital/figex/api/FigmaApi.kt @@ -91,7 +91,9 @@ class FigmaApi( onDownload { bytesSentTotal, contentLength -> status("Loading file $fileKey (${bytesSentTotal / 1024}KiB)") } - }.body() + }.body().copy( + fileKey = fileKey + ) internal suspend fun loadVariable( references: List, diff --git a/figex-core/src/main/kotlin/com/iodigital/figex/models/figma/FigmaFile.kt b/figex-core/src/main/kotlin/com/iodigital/figex/models/figma/FigmaFile.kt index 8bc2ac0..e6fb06c 100644 --- a/figex-core/src/main/kotlin/com/iodigital/figex/models/figma/FigmaFile.kt +++ b/figex-core/src/main/kotlin/com/iodigital/figex/models/figma/FigmaFile.kt @@ -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", ) } \ No newline at end of file diff --git a/samples/android_values.xml.figex b/samples/android_values.xml.figex index ff9dad9..ccc45f1 100644 --- a/samples/android_values.xml.figex +++ b/samples/android_values.xml.figex @@ -2,6 +2,7 @@ +