Let’s say I want to extract a frontmatter property of a reference of the form “author2025” residing in another note. I want to convert that link string to a dataview object, so I could retrieve a property from it, like page.year.
I have tried
```dataviewjs
let page = dv.page("[author2025](author2025.md)")
console.log(page)
```
but throws “undefined”. I am trying not to use regex.
Couldn’t find a dataview native way of converting the link to a page object. So, ended up using regex:
```dataviewjs
const tp = app.plugins.plugins["templater-obsidian"].templater.current_functions_object;
// original link
const link_str = "[@Brunton2016b](@Brunton2016b.md)"
// extract the citation text between square brackets "@Brunton2016b"
const page_obj = dv.page(link_str.match(/\[(.*)\]/)[1])
// convert string to a formatted date
const date = tp.date.now("YYYY-MM-DD", 0, page_obj.uuid.slice(0, 8), "YYYYMMDD")
console.log(date)
```
So, this works: dv.page("author2025")
But this will not: dv.page("[author2025](author2025.md)")
The link string "[@Brunton2016b](@Brunton2016b.md)" is stored under an online property called paperCitation in a note making reference to a paper. I just wanted to add the date that referenced note was created, from there my interest in getting the dataview page object. That, unfortunately, in all the forms I tried from the Dataview documentation. I also tried dv.parse, which returns the same string.
dv.page is smart enough to return a page object of a simpler string, “@Brunton2016b”, but no more and no less.
I have updated the script with an improved version that catches two types of Obsidian note links:
[[@author2025]], and
[@author2025](@author2025.md)
The former is a typed, unresolved link. The latter is a resolved link.
To extract a frontmatter property in both cases, use the script:
```dataviewjs
const tp = app.plugins.plugins["templater-obsidian"].templater.current_functions_object;
// original link
const link_str = "[@Brunton2016b](@Brunton2016b.md)" // resolved link
const link_str = "[[@Brunton2016b]]" // unresolved
// extract the citation text between square brackets "[@Brunton2016b]",
// or "[[@Brunton2016b]]"
const page_obj = dv.page(link_str.match(/\[{1,2}(.*?)\]{1,2}/)[1])
// convert string to a formatted date
const date = tp.date.now("YYYY-MM-DD", 0, page_obj.uuid.slice(0, 8), "YYYYMMDD")
console.log(date)
```