-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Support for websites located in subdirectories #142
Comments
I don't understand the issue. Are you talking about |
Sorry that I was not able to describe it better. Yes, that is the problem.
A better (IMHO) solution would be to be able to specify the subfolder on the command line `generate --domain /my-site". My current solution is to read from the environment: main :: IO ()
main = do
subdir <- maybe (pure [absdir|/|]) parseAbsDir
=<< lookupEnv "SUBDIR"
Rib.run [reldir|content|] [reldir|dest|] (generateSite subdir) The subdir can be used to describe a lref_ :: Path Rel Path -> Route a -> Attribute
lref_ subdir r =
href_ . Text.pack
. Path.toFilePath
$ subdir </> fromMaybe (error "unexpected") (Rib.routeFile r) Now this can be used in html generation. The example from before: a_ [ lref_ subdir r ] "The Internal Link" This solves two things. It makes route refences more typesafe, and Note: Ideally a |
Gotcha. I got confused by words like 'directory', 'subdir', etc. (filesystem notions), but the request is basically to customize the route URL (filesystem paths remain the same). What you are asking for, IIUC, is a custom "base URL" (whose default value is Let's say we extend -- | The absolute URL to this route (relative to the given site root)
routeUrlFrom :: IsRoute r => Text -> r a -> Text
routeUrlFrom baseUrl r = baseUrl </> routeUrl' Relative r Then you can use it as: a_ [href_ $ routeUrlFrom baseUrl r] ... Now the question becomes how to pass this All that's left at this point is to take this value from the CLI. Here's where I think different to your proposal. Instead of encoding this concept in # Everything before "rib" is from user code; everything after "rib" is from rib's CLI parser
$ mysite --base-url=/foo/ rib generate ... See here for an example of how this can be done. With this approach, the only change we would need to make to rib is to add a How does that sound? |
Ah.. baseUrl. Sometimes I just look the right words. I think that would be a great solution. Three comments:
|
In the beginning of the project, rib used to have unnecessarily sophisticated design, like using type classes (where none was needed); so these days I'm cautious of adding any general patterns. Personally I would implement whatever functionality in at least two of my sites before attempting to extract the general pattern into rib. By the way, there is also the Zulip discussion channel for Rib. |
Currently rib expect that the destination path will be in the root of the domain.
My website might be located at "domain.com/my-site", but rib expect everything
to be in "domain.com". This is quite common for university websites.
It would be nice if a sub-folder prefix could be automatically added. Something like:
The text was updated successfully, but these errors were encountered: