Links to the headers generated by dv.header()

Things I have tried

Within “alphabet.md”, I generated the headers by

for (var j=0; j < 26 ; j++) {
   let alphabet = String.fromCharCode(97 + j);
   dv.header(3, alphabet);
}

What I’m trying to do

I’m trying to make links to the headers generated the above dv code.

It looks like that something like [[alphabet#a]] doesn’t work.

I’d like to know if there is any way to make links to the dv.headers.

I am not sure that there is. All codeblocks including dataview are rendered with different logic than the rest of the Obsidian document.

Thank you for your comment.

If there isn’t at this moment, I hope it can be possible sometime later.

Topic

Summary
  • How to get the links of the headers where each of the headings contains at least one list item or one task item?(DQL10)
  • How to create the links to the headers?(DVJS10)

Test

Summary
  • dataview: v0.5.46

Input

Summary

the current note

  • Location: “100_Project/01_dataviewjs/01_by_example/Q88_header/Q88_test_data”
  • filename : alphabet
---
Date: 1995-03-01
---


### input_data
#### a
- a1
- a2

#### b
- b1
- b2

#### c
- [ ] c1
- [ ] c2

#### d
- [ ] d1
- [ ] d2

#### e
- [ ] e1
- [ ] e2

#### f




DQL10_flatten_fLists_groupBy_L_header_and_display_the_links_of_the_headers

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL10_flatten_fLists
_groupBy_L_header
_and_display_the_headers
file.lists yes 1.To flatten file.lists
2.To gather the links of the headers where each of the headings contains at least one list item or one task item
3.To group by L.header and let G_L_header = rows.L.header;
4.To display G_L_header as a list
The DQL10 is based on DQL90 in the following topic.
- Solutions: by Justdoitcc

Code DQL10_flatten_fLists_groupBy_L_header_and_display_the_links_of_the_headers

Summary_code
title: DQL10_flatten_fLists_groupBy_L_header_and_display_the_links_of_the_headers =>1.To flatten file.lists 2.To gather the links of the headers where each of the headings contains at least one list item or one task item 3.To group by L.header and `let G_L_header = rows.L.header;` 4.To display G_L_header as a list
collapse: close
icon: 
color: 
```dataview
LIST WITHOUT ID
     G_L_header

FROM "100_Project/01_dataviewjs/01_by_example/Q88_header/Q88_test_data"

FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
WHERE F_type = "header"
GROUP BY L.header AS G_L_header


```

Screenshots(DQL10)


DVJS10_create_links_to_headers

Summary

Main DVJS

Code Name Data type Group By Purposes Remark
DVJS10_create_links_to_headers a link like [[alphabet#a]] no To create the links to the headers

code DVJS10_create_links_to_headers

Summary_code
title: DVJS10_create_links_to_headers =>To create the links to the headers 
collapse: close
icon: 
color: 
```dataviewjs
// M11. define pages: gather all relevant pages
// #####################################################################
// let pages = dv
//     .pages('"100_Project/01_dataviewjs/01_by_example/Q88_header/Q88_test_data"')
//     .where((page) => dv.func.contains(page.file.name, "dic_"));     
let pages = dv.current();


// M13. define s_filename:
// #####################################################################
let s_filename = pages.file.name;


// M21. define n_QTY:
// #####################################################################
const n_QTY = 5; // from a to e


// M31. output s_link:
// #####################################################################
for (let j = 0; j < n_QTY ; j++) {

     // M31.FR11 define char_from_a_to_z:
     // #####################################################################
     let char_from_a_to_z = String.fromCharCode(97 + j);

     
     // M31.FR13 define s_link: \[[alphabet#a|a]\] 
     // #####################################################################
     //let s_link =  "[[" + "alphabet" + "#" + "a" +"]]";//=>alphabet > a
     
     //let s_link =  "[[" + "alphabet" + "#" + "a" +"|a]]";//=>a     
     //let s_link = dv.sectionLink(s_filename, char_from_a_to_z, false, char_from_a_to_z);//=>a
     let s_link =  "[[" + s_filename + "#" + char_from_a_to_z + "|" + char_from_a_to_z + "]]";
          
     
     // M31.FR15 output s_link:
     // #####################################################################
     dv.header(3, s_link);
     
}

```

Screenshots(DVJS10):


Reference

Summary

Thank you for your help.

But, the situation is a little different.
What I want to do is linking to the headers which are “generated by dv.header()”, not creating the links by dv.header().

1 Like
  • You could look at the DQL10 ,added on 2021-02-08.
  • It deals with the following problem.
    • How to get the links of the headers where each of the headings contains at least one list item or one task item?