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

Nested "extra" files and static asset links. #40

Closed
ryan-roemer opened this issue Apr 17, 2012 · 3 comments
Closed

Nested "extra" files and static asset links. #40

ryan-roemer opened this issue Apr 17, 2012 · 3 comments

Comments

@ryan-roemer
Copy link

I'm trying to add in directories of "extra" markdown files, but the static asset links aren't correctly being generated (say for directory "foo/bar/my_file.md"). I think the following diff will fix this:

$ git diff src/generator.coffee 
diff --git a/src/generator.coffee b/src/generator.coffee
index cf2adda..de59d73 100644
--- a/src/generator.coffee
+++ b/src/generator.coffee
@@ -126,10 +126,16 @@ module.exports = class Generator
       try
         content = fs.readFileSync extra, 'utf-8'
         content = marked content if /\.(markdown|md)$/.test extra
+        numSlashes = extra.split('/').length - 1
+        assetPath = ''
+        assetPath += '../' for slash in [0...numSlashes]
         filename = "#{ extra }.html"
+
         @templater.render 'file', {
-          path: ''
+          path: assetPath
           filename: extra,
           content: content
           breadcrumbs: [

I'm not doing a pull request, as I don't fully understand the generation path, and I'm very behind the curve on using Guard for auto-gen, and what I have done so far gens a lot of extra JS code.

So, hopefully this points in the right direction. If there is a different way to get nested directories of markdown files correctly included, please let me know.

@netzpirat
Copy link
Contributor

Thats a great patch, works fine. Thanks a lot!

The code is necessary since code creates relative links, so that the docs can be browsed with the file:// protocol. It simply counts how deep it's nested and creates the backward path to the assets folder.

@ryan-roemer
Copy link
Author

Thanks for the fix and the quick turnaround!

Installed off master tarball, and works for me. One other note -- the "Index » path/to/my/extra_doc.md" link in the rendered page frame doesn't seem to work with the extra files. But, I can definitely live with this and it may just be some artifact of something I did, so I won't open a new ticket.

@netzpirat
Copy link
Contributor

Thanks for spotting the breadcrumb issue, I've fixed it.

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