-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom page preview: Automatic generation using plugins #1
Comments
The issue seems to be that your Dataviewjs block creates the callout at a different position in the DOM than normal, and my CSS doesn't account for that. Could be solved by changing the CSS, but here's a different way to do it with Dataview without changing the CSS:
I think there might be a simpler way to do the image embed, but not sure, I'm not that familiar with Dataview. This also seems to render unreliably in Live Preview for me. |
Depending on your needs, another option would be to mark the values as Dataview inline fields (instead of storing them in the yaml):
And a snippet to reset their appearance: .dataview.inline-field-standalone-value {
padding: 0;
font-family: inherit;
background-color: transparent;
color: inherit;
} |
I check both solution but non are really good solutions :D What about trying the way by adaption of CSS? |
Here's a patched version for you (Warning: Probably broken): Custom page preview (ignore position).css. I removed everything that checks the exact position of the page preview in the DOM hierarchy. I also added an extra use of the I think the better solution would be to find out how to generate the correct html output using DataviewJS or Templater if possible. edit: To avoid the margins added by the paragraph element you're creating, use a div instead: dv.el("div", "> [!page preview]\n> " + summary + "\n>\n ![[" + cover + "]]") |
If you want to stick to this solution (and assuming you run into issues with the patch), I could probably add additional checks to the snippet for the DataviewJS output for a more robust solution |
I have used your snippet above. My installer is 1.1.9. But the preview is different and as you see it is still visible in page. CODEcover: "Pasted image 20230126162029.png"
|
The screenshots look as if you don't have the snippet enabled This is how it looks like for me in the sandbox vault with just the patched snippet and Dataview installed (with JS queries enabled) Note content: ---
cover: "Pasted image 20230308145507.png"
summary: Testing view
---
```dataviewjs
let cover = dv.current().cover
let summary = dv.current().summary
dv.el("div", "> [!page preview]\n> " + summary + "\n>\n ![[" + cover + "]]")
``` |
I'd also be interested to hear what your issues were with the other solutions |
Now your code works! The custom CSS was disabled as I renamed it... Here is the script: Here is how you need to call it from note text: cover: "Pasted image 20230126162029.png"
|
Also there is a side affect, that the notes without this code are previewed empty |
I fixed that in patch 2 |
I have indeed fixed the side effect but now the the DataviewJS and neither dv.view methods are not producing preview. |
Hello.
I tried to replicate and build the text formatting from your snippet. To build the snippet automatically from note's metadata. But as you see the CSS is not behaving in same way if it is inserted as text.
Markdown
Preview mode
Do you have any ideas how to fix it? Possible with adding some CSS class?
The text was updated successfully, but these errors were encountered: