ddfreyne on main
Upgrade dependencies Use Bundler 2.x (compare)
ddfreyne on main
Upgrade nanoc, nanoc-live (compare)
ddfreyne on main
nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)
ddfreyne on 4.11.23
nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)
ddfreyne on nanoc-core-v4.11.23
nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)
ddfreyne on nanoc-cli-v4.11.23
nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)
ddfreyne on nanoc-live-v1.0.0b8
nanoc-live: Set version to 1.0.… nanoc-live: Add release notes f… Set version to 4.11.23 and 1 more (compare)
ddfreyne on main
Set up GitLab CI Merge branch 'gitlab-ci' into '… (compare)
ddfreyne on gitlab-ci
Set up GitLab CI wip (compare)
ddfreyne on debug-timeout
Debug why nanoc tests sometimes… (compare)
<%=link_to_unless_current("hello", "/.*")%>
should link to the page root. I get <a href="/.*">
, the literal link, instead. Am on the latest nanoc release and don't have legacy identifiers enabled 🤔
<%=link_to_unless_current("hello", "/")%>
, but only in the page content, not in the main menu partial (that itself invokes a ruby helper method to render the whole menu). I wonder if that's because @item
is not available in the helper module to check the context?
@DivineDominion Hey there! The second argument to link_to
/link_to_unless_current
is going to be exactly what ends up in the href
attribute.
If you want to link to a specifc item, you can use e.g. <%= link_to 'Home', @items['/home.*'] %>
— i.e. the second argument is the item you want to link to
link_to_unless_current('Blog', '/blog.*')
but that should be link_to_unless_current('Blog', @items['/blog.*'])
link_to_unless_current
helper produces a span
when I use it in e.g. overview/index.md
and it's part of the content, but the same call won't work in the nav bar (default
calls _navigation.erb.html
which uses lib/helpers/menu.rb
's render_menu
). The code to link_to_unless_current
is rather simple, too. My best guess would be that the partial is cached, but using puts @item.path + " -- " + @items["/overview.*"].path
reveals that this line is called for each item indeed, and that the ==
comparison inside link_to_unless_current
should be true. :/
Struct.new(...)
to represent menu item configurations, and have a render
method inside, and call link_to_unless_current
from there. @item_rep
is nil there. I think this is because of the way use_helper
includes the module itself (works from there), but not the module's inner Struct definitions
touch
each file that includes an "ENV"
in it, but that's kinda weird
@DivineDominion Are you using the ENV
variable directly in code? (e.g. <%= ENV['SOMETHING'] %>
) That’ll not work because Nanoc does not track changes to ENV
.
What you can do, is copy stuff from ENV
to @config
in the preprocessor, and then only use the stuff that you copied to @config
.
ENV
some 6 years ago because I found no other way. The environment stuff looks way better than what I have, though!
atom_feed(articles: @items.find_all('/blog2/*')
<%= atom_feed :limit => 50,
:articles => sorted_posts_by("sascha"),
:title => "Zettelkasten Posts by Sascha",
:author_name => "Sascha Fast",
:author_uri => "http://zettelkasten.de/authors/sascha/" %>
Hi, and first of all a big thank you to the Nanoc developers! I’ve been looking for an extensible static site generator and so far Nanoc seems to fit the bill perfectly: it’s quite bare-bones on the surface but the provided mechanisms for rules, helpers etc seem to be very powerful.
As I’m working on some features for our own workflow, I thought I’d bring them up here to see if anyone has any experience doing similar things, before I go on reinventing the wheel.
First, we’d like to have something like “page bundles” in Hugo where a page is based on a directory rather than a single file. So, for example, in a blog context, the main file for a post may be content/posts/my-post/index.md
, resulting in a URL of /posts/my-post
. In addition, it should be easy to refer to assets in that particular directory from the layout for the post. I did get something like this up-and-running already, just curious as to whether anyone else has done the same thing and come across any dos and don’ts?
Other static site generators provide mechanisms for managing URLs, for example in the case where your site runs in a subdirectory (like /blog/
) in production, but you’d like to link to assets without the /blog/
prefix internally. Does Nanoc have something built-in for managing this?
We often store so-called content in Markdown front matter: things like an intro or an excerpt for a blog post. It could be argued that these belong in separate Markdown files, but having them in the same file is convenient when it comes to editing. To that end, I’m wondering if it’s possible to run the front matter attributes for items through Markdown? Actually, considering that these attributes may include things like image tags and considering the subdirectory URL situation mentioned above, it would be great to even have ERB in the front matter, but this sounds like it might get complicated if you refer to item attributes from item attributes… Is there a better way to go about this?
Appreciate any input! Thank you!
Hey @klumme! I’ll give a brief answer to your points and we can go into more detail if you need it:
Nanoc doesn’t have the concept of page bundles, but it’s also quite flexible in where you put your stuff. I usually put assets (images and videos) in the directory that corresponds to the page, because it makes it easier to find things and this way I don’t end up with a giant assets or images directory.
For sites that run in subdirectories, there is the relativize_paths filter (https://nanoc.ws/doc/reference/filters/#relativize_paths). This way, Nanoc can pretend everything is an absolute path, and then afterwards make all the paths relative.
You could use the filtering helper (https://nanoc.ws/doc/reference/helpers/#filtering) and do something like <% filter :kramdown do %><%= item[:excerpt] %><% end %>
.
@items.detect {|item| item.path == <url>}
is no problem. However, it would be useful for the helper to establish a block inside which @item
is reassigned to the page we just looked up, instead of the rendered one — that way, other helpers and partials can be used in the same way both inside such a block and outside it, always referring to @item
. Given that this may be trivial, as I’m not yet that familiar with Ruby: is there a nice way to accomplish this in Nanoc?