Skip to content

Commit

Permalink
fix missing root
Browse files Browse the repository at this point in the history
  • Loading branch information
MatMoore committed Jun 28, 2024
1 parent 5c2c809 commit 47a88b8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/obsidian/parser/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ def self.legacy_initialize(title:, slug:, last_modified: nil, content: nil, pare
Page.new(tree, content_store, parent: parent, media_root: media_root)
end

def initialize(tree, content_store, parent: nil, media_root: nil)
def initialize(tree, content_store, parent: nil, root: nil, media_root: nil)
@tree = tree
@content_store = content_store
@content = content
@parent = parent
@media_root = media_root
@referenced = false
@child_pages = {}
@root = root || self
end

attr_reader :parent
Expand All @@ -85,6 +86,10 @@ def inspect
"Page(tree=#{@tree.inspect})"
end

def value
@tree.value
end

def uri
@tree.value.uri
end
Expand Down Expand Up @@ -173,7 +178,7 @@ def get_or_create_child(title:, slug:, last_modified: nil, content: nil, content

child = @tree.add_child_unless_exists(value)
@content_store[slug] = content unless content.nil?
page = Page.new(child, @content_store, parent: self, media_root: @media_root)
page = Page.new(child, @content_store, parent: self, root: root, media_root: media_root)
@child_pages[slug] ||= page
end

Expand Down

0 comments on commit 47a88b8

Please sign in to comment.