diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 61d452f..887d148 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,5 +1,6 @@ name: Deploy on: + pull_request: push: branches: - master @@ -35,6 +36,7 @@ jobs: run: cabal run blog - name: Upload artifact + if: github.ref == 'refs/heads/master' uses: actions/upload-pages-artifact@v3 with: path: ./build @@ -42,6 +44,7 @@ jobs: deploy: needs: build runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' permissions: pages: write diff --git a/articles/2020/open-source-journey.md b/articles/2020/open-source-journey.md index 9a3e361..7383121 100644 --- a/articles/2020/open-source-journey.md +++ b/articles/2020/open-source-journey.md @@ -3,13 +3,10 @@ title: My Open Source Journey author: Jan van Brügge date: 2020-10-28 tags: [open-source] +published_on: the [Futurice Blog](https://futurice.com/blog/my-open-source-journey) description: It's October again, Hacktoberfest time. Also time for me to reminisce about my personal learning journey that was so heavily influenced by open source. --- -*This post was first published on the [Futurice Blog](https://futurice.com/blog/my-open-source-journey).* - -It's October again, Hacktoberfest time. Also time for me to reminisce about my personal learning journey that was so heavily influenced by open source. - ## The Beginning My interest in computers and coding started rather early, so when I was 14 years old, I went to the local library, got myself a book about programming ("From Zero to Hero: Java") and started on this wonderful path that is now not only my job, but also my passion. diff --git a/articles/2020/redesigning-a-framework.md b/articles/2020/redesigning-a-framework.md index be08b3d..fbeb1d5 100644 --- a/articles/2020/redesigning-a-framework.md +++ b/articles/2020/redesigning-a-framework.md @@ -6,8 +6,6 @@ tags: [typescript, open-source] description: For the last few years, the core team of Cycle.js ([André](https://twitter.com/andrestaltz) and me) has been redesigning the architecture and the developer experience of the framework. This February we finally found a solution to our problems that still stays true to the core ideas of the framework. --- -For the last few years, the core team of Cycle.js ([André](https://twitter.com/andrestaltz) and me) has been redesigning the architecture and the developer experience of the framework. This February we finally found a solution to our problems that still stays true to the core ideas of the framework. - This blog post marks the first in a series that will cover the new design and its development. In this installment, I want to bring everyone onto the same page. _What_ where the problems I described earlier and _how_ does the new design solve them. In the later articles I will cover the new `run` function (the core of the framework) and the new HTTP driver and especially the issues I encountered while implementing those. _\*cough\*_ race conditions _\*cough\*_. ## The status quo diff --git a/blog.cabal b/blog.cabal index 428bc3d..0b23045 100644 --- a/blog.cabal +++ b/blog.cabal @@ -23,6 +23,7 @@ executable blog build-depends: base ^>=4.18.0.0 , containers , aeson + , pandoc , slick , shake , text diff --git a/src/Main.hs b/src/Main.hs index f919a8f..dcc2947 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -3,32 +3,47 @@ module Main where -import Development.Shake (ShakeOptions(..), shakeOptions, Verbosity (..), Action, forP, getDirectoryFiles, readFile', writeFile', copyFileChanged) -import Development.Shake.Forward (forwardOptions, shakeArgsForward, cacheAction) -import GHC.Generics (Generic) -import Development.Shake.Classes (Binary) +import Control.Monad (foldM) +import Control.Monad.IO.Class (liftIO) import Data.Aeson (FromJSON, ToJSON) -import Data.Aeson.Types qualified as A -import Data.Text qualified as T -import Slick (markdownToHTML, compileTemplate', substitute) -import Slick.Utils (convert) +import Data.Aeson.Key (fromText) import Data.Aeson.KeyMap qualified as KM -import Development.Shake.FilePath (dropDirectory1, (), dropExtension) +import Data.Aeson.Types qualified as A import Data.Functor (void) -import Data.Maybe (fromMaybe) -import Control.Monad (foldM) -import Data.Aeson.Key (fromText) import Data.List (sortOn) +import Data.Maybe (fromMaybe) import Data.Ord (Down(..)) import Data.Set qualified as Set +import Data.Text qualified as T +import Development.Shake (ShakeOptions(..), shakeOptions, Verbosity (..), Action, forP, getDirectoryFiles, readFile', writeFile', copyFileChanged) +import Development.Shake.Classes (Binary) +import Development.Shake.FilePath (dropDirectory1, (), dropExtension) +import Development.Shake.Forward (forwardOptions, shakeArgsForward, cacheAction) +import GHC.Generics (Generic) +import Slick (compileTemplate', substitute) +import Slick.Pandoc (loadUsingMeta, defaultHtml5Options, defaultMarkdownOptions) +import Slick.Utils (convert) +import Text.Pandoc.Options (writerTableOfContents, writerTemplate) +import Text.Pandoc.Readers (readMarkdown) +import Text.Pandoc.Templates (compileTemplate) +import Text.Pandoc.Writers (writeHtml5String) outputFolder :: FilePath outputFolder = "build/" +markdownToHTML :: T.Text -> Action A.Value +markdownToHTML txt = do + Right x <- liftIO $ compileTemplate "" "

Table of Contents

\n$toc$\n$body$" + loadUsingMeta (readMarkdown defaultMarkdownOptions) + (writeHtml5String (defaultHtml5Options { writerTableOfContents = True, writerTemplate = Just x })) + (writeHtml5String defaultHtml5Options) + txt + data Post = MkPost { title :: String , author :: String , description :: String + , published_on :: Maybe String , content :: String , url :: String , date :: String diff --git a/templates/post.html b/templates/post.html index d0f4187..a82c095 100644 --- a/templates/post.html +++ b/templates/post.html @@ -1,4 +1,10 @@
{{> templates/postHeader.html}} + {{#published_on}} +

This post was first published on {{{.}}}.

+ {{/published_on}} +

+ {{{description}}} +

{{{content}}}
diff --git a/templates/postList.html b/templates/postList.html index 68c4761..253a058 100644 --- a/templates/postList.html +++ b/templates/postList.html @@ -5,6 +5,6 @@
{{> templates/postHeader.html}} {{{description}}} - Read more +
Read more
{{/posts}} diff --git a/templates/shell.html b/templates/shell.html index 62bf5ee..a2c6b72 100644 --- a/templates/shell.html +++ b/templates/shell.html @@ -23,6 +23,7 @@ © 2020-2024, Jan van Brügge. Opinions are my own. All articles licensed under CC BY-SA 4.0 Feeds are available via Atom + Site generated with Haskell and Slick. See the source on GitHub.