- // set the file name
- std::string filepath = this->stub_hierarchy () +
- this->stub;
- // create the sidebar
- std::unique_ptr<SideBar> bar (new SideBar ());
- bar.get()->set_title (this->title);
+ // set the file name path
+ std::string filepath = destdir + "/" + this->stub_hierarchy () + this->stub;
+ // set the url path - this should not have destdir as it is not part
+ // of the site tree
+ std::string urlpath = this->stub_hierarchy () + this->stub;
+ // if urlpath is not empty then append a / to the end of the URL. This
+ // is so that the base URL is not absolute
+ if (urlpath != "")
+ urlpath += "/";
+
+ // create the sidebars
+ // First sidebar
+ // Create a link to the index page and
+ // If this tree has a parent, create a sidebar link to the level up
+ std::unique_ptr<SideBar> bar1 (new SideBar());
+ SideBarItem item0;
+ item0.set_sidebar_text (INDEX);
+ item0.set_sidebar_url (urlpath + "index.html");
+ bar1.get()->add_sidebar_item (item0);
+ if (this->get_parent() != nullptr) {
+ SideBarItem item1;
+ item1.set_sidebar_text (GO_UP);
+ item1.set_sidebar_url (this->stub_hierarchy() + "index.html");
+ bar1.get()->add_sidebar_item (item1);
+ }
+ index.get()->add_side_bar (*bar1.get());
+
+ // create a sidebar for the child levels if there are children
+ std::unique_ptr<SideBar> bar2 (new SideBar ());
+ bar2.get()->set_title (SUB_CAT + this->title);