so, on my glossary page, I am using it to convert a name e.g. "Category Theory" into "category-theory". Its really just a generally useful thing to have. It might also be handy if you had some common source from which you wanted to generate a bunch of individual html pages. Like lets say you had a source with a bunch of e.g. "Diet and Exercise 12-12-2019" this helps you convert it to "diet-and-exercise-12-12-2019"
Also, more generally speaking, a good approach to figure out how to add functionality to RIb would be to add the said functionality to your own static site first, and then see if it can be extracted in general fashion to be included in Rib for use with other static sites.
I was hoping that the directory structure of the source area would be replicated in the target, that is, a/some/path/index.md would end up at b/some/path/index.html. Is there a way to get this to w...
@Joel McCracken I think a newtype Slug = Slug { unSlug :: Path Rel File } would definitely be a good thing. Feel free to open a PR for it. Then we extend rib's buildHtmlMulti (for Jonathan's case) to take in a Path Rel File -> Slug function (default being foo.md -> foo.html) that allows the user to customize it to their needs.
dataSlugBuilder=SlugBuilder_Simple--- Just replaces extension|SlugBuilder_Clean-- No .html suffix|SlugBuilder_Custom(FilePath->FilePath)mkSlug::FilePath->SlugBuilder->SlugmkSlugpath=Slug.\caseSlugBuilder_Simple->replaceExtension".html"pathSlugBuilder_Clean->T.replace".md""/index.html"pathSlugBuilder_Customf->fpath
And then have buildHtmlMulti take in the SlugBuilder as an argument.
That's one approach I can think of. Wonder if it can be simplified ....
So I am making a string sluggification thing, extracting it from https://hackage.haskell.org/package/slug-0.1.7/docs/src/Web-Slug.html#mkSlug
I figure it could be useful in general though
i can submit a PR if you can give any guidance to where you think it should go, etc
I wasnt going to bother with adding a
newtype Slug = Slug Text
but if you think I should then thats fineWhere would you use the slug type in rib?
so, on my glossary page, I am using it to convert a name e.g. "Category Theory" into "category-theory". Its really just a generally useful thing to have. It might also be handy if you had some common source from which you wanted to generate a bunch of individual html pages. Like lets say you had a source with a bunch of e.g. "Diet and Exercise 12-12-2019" this helps you convert it to "diet-and-exercise-12-12-2019"
I don't think I really understand how this would fit in with existing Rib API. Perhaps if you can show me code example ....
Presently,
Path Rel File
is used inSource
to denote any slug. I think that's reasonable given that these slugs map to file on the disk anyway.Also, more generally speaking, a good approach to figure out how to add functionality to RIb would be to add the said functionality to your own static site first, and then see if it can be extracted in general fashion to be included in Rib for use with other static sites.
sure; i implemented this last night, it wasn't too hard
Turns out I actually found some use for this Slug site in my static site today. Here's another point of integration: https://github.com/srid/rib/issues/77#issuecomment-571402658
@Joel McCracken I think a
newtype Slug = Slug { unSlug :: Path Rel File }
would definitely be a good thing. Feel free to open a PR for it. Then we extend rib's buildHtmlMulti (for Jonathan's case) to take in aPath Rel File -> Slug
function (default being foo.md -> foo.html) that allows the user to customize it to their needs.The
Slug
type would basically be used by the_source_url
field of theSource
record.And we can also have,
And then have
buildHtmlMulti
take in theSlugBuilder
as an argument.That's one approach I can think of. Wonder if it can be simplified ....
One thing I don't like about the API is that these functions tend to take too many arguments.
actually, just do:
type SlugBuilder = FilePath -> FilePath
and be done with it. Then we only need the defaults: