Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pbrisbin/yesod-links
Convenience functions for creating link widgets to types
https://github.com/pbrisbin/yesod-links
Last synced: about 2 months ago
JSON representation
Convenience functions for creating link widgets to types
- Host: GitHub
- URL: https://github.com/pbrisbin/yesod-links
- Owner: pbrisbin
- License: bsd-3-clause
- Created: 2012-04-13T01:38:37.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-05-30T22:57:06.000Z (over 11 years ago)
- Last Synced: 2024-10-09T09:44:07.658Z (3 months ago)
- Language: Haskell
- Homepage:
- Size: 109 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yesod links
~~~ { .haskell }
import Yesod.Linksinstance YesodLinked MySite where
type Linked = MySite
~~~Make concise link-widgets by defining how things should be represented
as links.~~~ { .haskell }
--
-- * Make linking to any specific route simpler
--
instance IsLink MySiteRoute where
toLink RootR = Link (Internal RootR) "go home" "home"
toLink AboutR = Link (Internal AboutR) "about this site" "about"getRootR :: Handler RepHtml
getRootR = defaultLayout $ do
[whamlet|be sure to visit our ^{link AboutR} page.
|]
--
-- * Use it for more than just routes
--
data Post = Post
{ postSlug :: Text
, postTitle :: Text
, postDescr :: Text
}instance IsLink Post where
toLink (Post s t d) = Link (Internal $ PostR s) d tgetIndexR :: Handler RepHtml
getIndexR = defaultLayout do
[whamlet|
- ^{link post}
|]--
-- * Bypass the IsLink instance and use the raw link' function for
-- external links
--
getAboutR :: Handler RepHtml
getAboutR = defaultLayout $ do
[whamlet|
be sure to checkout my ^{link' github} profile.|]
where
github :: Link MySite
github = Link (External "https://github.com/pbrisbin") "my github repos" "github"
~~~
$forall post <- posts