diff --git a/README.md b/README.md index f092af9..9e573e4 100644 --- a/README.md +++ b/README.md @@ -23,18 +23,14 @@ frame: YOUR FRAME'S NAME ``` ~~~ -Optionally, you can also pass custom style settings to the embed, which allows you to change things like the embed's height: -~~~ -```custom-frames -frame: YOUR FRAME'S NAME -style: SOME CSS -~~~ +Optionally, you can also pass custom style settings to the embed, which allows you to change things like the embed's height, as well as an additional suffix that will be appended to the frame's regular URL, which can be useful for things like displaying a specific note in Google Keep. -Here's an example that creates a very tall embed using the [Google Keep preset](#-presets): +Here's an example using the [Google Keep preset](#-presets): ~~~ ```custom-frames frame: Google Keep style: height: 1000px; +urlSuffix: #reminders ``` ~~~ diff --git a/src/frame.ts b/src/frame.ts index f12e705..098ebc0 100644 --- a/src/frame.ts +++ b/src/frame.ts @@ -12,7 +12,7 @@ export class CustomFrame { this.data = data; } - public create(additionalStyle: string = undefined): any { + public create(additionalStyle: string = undefined, urlSuffix: string = undefined): any { let style = `padding: ${this.settings.padding}px;`; if (additionalStyle) style += additionalStyle; @@ -32,7 +32,15 @@ export class CustomFrame { } this.frame.addClass("custom-frames-frame"); this.frame.setAttribute("style", style); - this.frame.setAttribute("src", this.data.url); + + let src = this.data.url; + if (urlSuffix) { + if (!urlSuffix.startsWith("/")) + src += "/"; + src += urlSuffix; + } + this.frame.setAttribute("src", src); + return this.frame; } diff --git a/src/main.ts b/src/main.ts index d6c86bd..e451fa0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -63,8 +63,12 @@ export default class CustomFramesPlugin extends Plugin { let style = styleMatch && styleMatch[1].trim(); style ||= "height: 600px;"; + let urlSuffixMatch = /urlsuffix:([^\n]+)/gi.exec(s); + let urlSuffix = urlSuffixMatch && urlSuffixMatch[1].trim(); + urlSuffix ||= ""; + let frame = new CustomFrame(this.settings, data); - e.appendChild(frame.create(style)); + e.appendChild(frame.create(style, urlSuffix)); }); }