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

Sitemap generator ~ slugs object #131

Closed
kbsali opened this issue Oct 18, 2013 · 9 comments
Closed

Sitemap generator ~ slugs object #131

kbsali opened this issue Oct 18, 2013 · 9 comments
Assignees
Labels

Comments

@kbsali
Copy link

@kbsali kbsali commented Oct 18, 2013

It would be nice to be able to generate a sitemap of all the published slugs,
or maybe have a global object slugs listing them all

@kennethormandy
Copy link
Collaborator

@kennethormandy kennethormandy commented Oct 18, 2013

Sorry, my initial advice was totally off. It should be possible already, though, we’ll put together an example.

@ghost ghost assigned kennethormandy Oct 18, 2013
@kennethormandy
Copy link
Collaborator

@kennethormandy kennethormandy commented Oct 27, 2013

@kbsali Sorry it took a bit, here’s a pretty impressive solution from @sintaxi:

mixin tree(head, tail)
  for val, key in head
    if key !== '.git' && key !== 'data'
      if key == 'contents'
        each file in val
          p= tail + file
      else
        mixin tree(val, tail + key + "/")

h1 Sitemap
mixin tree(public, "/")

I’m going to leave this issue open as we’re still expanding on this for use with manifest files, etc. and it all needs to go into the docs somewhere.

@kbsali
Copy link
Author

@kbsali kbsali commented Oct 28, 2013

@kennethormandy
Copy link
Collaborator

@kennethormandy kennethormandy commented Oct 28, 2013

No problem, nice writeup. I definitely don’t deserve credit, though, @sintaxi put it all together.

I’m not sure how you approached doing published and unpublished posts, but if you’re just setting posts to published: false or something similar, I think you should be able to check for that as you iterate through your content. If you’re naming the posts with an underscore at the beginning, then they should be excluded automatically.

@kbsali
Copy link
Author

@kbsali kbsali commented Nov 19, 2013

@kennethormandy @sintaxi i upgraded to v0.10.0 and was writting a post on how easy the move went,
but i'm having an issue with the sitemap snippet, here is the error i'm getting when compiling my project :

{
  "source": "Jade",
  "dest": "HTML",
  "filename": "/.../public/sitemap.xml.jade",
  "lineno": 4,
  "name": "RangeError",
  "message": "Maximum call stack size exceeded",
  "stack": "mixin tree(head, tail)\n  for val, key in head\n    if key !== '.git' && key !== 'data'\n      if key == 'contents'\n        each file in val\n          if /(\\.html$)/.test(file)\n            prio = .4\n            if /about/.test(tail + file)\n              prio = .9\n            if /posts/.test(tail + file)\n              prio = .7\n            if /index/.test(tail + file)\n              prio = .6\n            url\n              loc= site_url + tail + file\n              priority= prio\n      else\n        mixin tree(val, tail + key + \"/\")\n\ndoctype xml\nurlset(xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\")\n  mixin tree(public, \"/\")\n"
}

Any hints on how to get this fixed?

thx

@kennethormandy
Copy link
Collaborator

@kennethormandy kennethormandy commented Nov 19, 2013

@kbsali The update to the original one would be:

mixin tree(head, tail)
  for val, key in head
    if key !== '_data'
      if key == '_contents'
        each file in val
          p= tail + file
      else
        mixin tree(val, tail + key + "/")

h1 Sitemap
mixin tree(public, "/")

You shouldn’t need to check for the . files anymore in v0.10.0, either, so I’ve removed that.

@kbsali
Copy link
Author

@kbsali kbsali commented Nov 19, 2013

@kennethormandy man that was a quick answer!
Awesome, thanks a lot! 👍

@edrex
Copy link
Contributor

@edrex edrex commented Nov 22, 2013

Another example, using JS one-liners inside Jade: sitemap.xml.jade and _shared/deep.jade.

@kennethormandy
Copy link
Collaborator

@kennethormandy kennethormandy commented Dec 17, 2013

We’ve collected some useful patterns and snippets for Harp in the Harp recipes section. If you’re looking how to make a sitemap, take a look at this sitemap recipe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.