Skip to content
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

How do I create cards dynamically (dataviewjs)? #73

Open
Dartaltram opened this issue Jan 13, 2024 · 1 comment
Open

How do I create cards dynamically (dataviewjs)? #73

Dartaltram opened this issue Jan 13, 2024 · 1 comment

Comments

@Dartaltram
Copy link

I have several notes with the "#card" tag and want to summarise them in a card gallery, but when I print the correct syntax (as opposed to manually typing it out) the result is a simple markdown nested list

Note source

# Title!

- ## Card #mcl/list-card
    - some text
    - some text

```dataviewjs

    const cards = dv.pages('"zzzzzzzzzz"').file
        .where(c => c.tags.includes('#card'))

    dv.span(
        "- ### PLACE #mcl/list-card\n" +
        "    - aaaaa\n" +
        "    - bbbbb\n"
    )
\```

---

`$= '- ### another PLACE #mcl/list-card\n    - aaaa\n    - bbb\n'`

---


<%* tR += "- ### PLACE #mcl/list-card\n    - aaaaa\n    - bbbbb\n" %>

As can be seen the first lines are an example of a manually typed out card

Then there's a block taking all the cards from the test folder "zzzzzzzzzz" and bearing the tag "#card". The original idea was to print them in a for cycle but let's start small.

Trying to print the syntax with a dv.paragraph or a dv.span didn't work correctly and neither does using an inline dv, as shown in the picture below. Applying a template like the one in the last line WILL work, but it is obviously not dynamic

Current Behaviour

image

Here I put the result in Reading View after applying the template

Suggestions?

@efemkay
Copy link
Owner

efemkay commented Jan 25, 2024

unfortunately i have very little working knowledge of dataview syntax. not sure if that's even possible.

templater would translate the template syntax into markdown upon creation (of the note), hence why it works. as far i know, dataview would do that dynamically and doesn't permanently convert to markdown syntax. you can try obsidian discord dataview thread in case it is somewhat possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants