Skip to content

Commit

Permalink
62 rss feed (#64)
Browse files Browse the repository at this point in the history
* Add clojure blog post rss feed

Use markdown-clj to convert the content to html. Use clj-rss to create the rss feed. Only include the clojure articles in the rss feed.

* Add CI step to generate the rss feed at compile time

* Add description to blog articles.

* Add empty rss feed

* Items in rss feed are sorted by date
  • Loading branch information
skydread1 authored Aug 30, 2024
1 parent 95e28fa commit f61b6fe
Show file tree
Hide file tree
Showing 25 changed files with 2,859 additions and 1,162 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,23 @@ jobs:
run: clojure -T:cljfmt check

- name: Run the clj tests
run: clojure -A:server/test
run: clojure -M:server/test

- name: Run the cljs tests
run: clojure -A:web/test-headless
run: clojure -M:web/test-headless

- name: Build main.js
run: clojure -T:build js-bundle

- uses: EndBug/add-and-commit@v9
- name: Generate RSS feed
run: clojure -T:build rss-feed

- name: Commit js bundle and rss feed
uses: EndBug/add-and-commit@v9
with:
add: "resources/public/main.js"
add: |
resources/public/main.js
resources/public/blog/rss/clojure-feed.xml
committer_name: GitHub Action
default_author: github_actions
message: "Compiled the cljs to the js bundle: main.js"
message: "Compile the cljs to the js bundle and update RSS feed"
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The routing is done with [reitit](https://github.com/metosin/reitit).

The markdown content is converted into [hiccup](https://github.com/weavejester/hiccup) (a clojure-friendly markup) and the post/vignette configurations are made in EDN which is validated at compile time with a [malli](https://github.com/metosin/malli) schema.

At compile time, a RSS feed is generated for the clojure blog posts using [clj-rss](https://github.com/yogthos/clj-rss).

The app is deployed on **Netlify** every time a branch is merged to master.

## 🔷 Features
Expand Down Expand Up @@ -165,6 +167,8 @@ However, if you change the content of a markdown file, you will need to save the

### Prod

#### Js bundle

The GitHub action is triggered when code is pushed.

I use [clojure/tools.build](https://github.com/clojure/tools.build) to create tasks related to the build.
Expand All @@ -179,14 +183,24 @@ This command compiles the cljs to the optimized js bundle that Netlify will use

Note: be sure to not forget to use `main.js` as script source in [index.html](./resources/public/index.html): that is where figwheel will produce the optimize js from your cljs file when you push your update to your online repo.

#### RSS feed

A RSS feed of the Clojure blog posts is also generated when code is pushed:

```
clojure -T:build rss-feed
```

The RSS **clojure** feed is accessible at the url [blog/rss/clojure-feed.xml](https://www.loicblanchard.me/blog/rss/clojure-feed.xml)

## 🔷 Tests

### Clj tests

The clj macro that loads the markdown files is tested and the test can be run like so:

```clojure
clj -A:server/test
clj -M:server/test
```

This test ensure that all your markdown files respect the malli schema.
Expand All @@ -196,7 +210,7 @@ This test ensure that all your markdown files respect the malli schema.
The cljs state management tests can be run like so:

```clojure
clj -A:web/test
clj -M:web/test
```

These frontend cljs tests ensure that the state (in our re-frame DB) is as expected after user actions (navigation, theme, post interaction etc).
Expand All @@ -210,7 +224,7 @@ The tests mentioned above are also run on every save and the results are display
In the CI, there is no browser, so we need a specific alias to run the test in headless mode:

```clojure
clj -A::web/test-headless
clj -M::web/test-headless
```

## 🔷 Continuous Integration
Expand Down
7 changes: 6 additions & 1 deletion build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
[_]
(clean nil)
(b/process {:command-args ["clojure" "-M:web/prod"]})
(clean nil))
(clean nil))

(defn rss-feed
"Generate RSS feed from the markdown file for the Clojure blog posts."
[_]
(b/process {:command-args ["clojure" "-M:rss"]}))
6 changes: 5 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
re-frame/re-frame {:mvn/version "1.4.2"}
reagent/reagent {:mvn/version "1.2.0"}
sg.flybot/lasagna-pull {:mvn/version "0.4.156"}
tick/tick {:mvn/version "0.7.5"}}
tick/tick {:mvn/version "0.7.5"}
markdown-clj/markdown-clj {:mvn/version "1.12.1"}
clj-rss/clj-rss {:mvn/version "0.4.0"}}
:paths ["src" "resources" "target" "test"]
:aliases
{;; Run clj tests
Expand Down Expand Up @@ -43,6 +45,8 @@
:web/test-headless {:main-opts ["-m" "figwheel.main"
"-co" "tests.cljs.edn"
"-m" "loicb.client.test-runner"]}
;; RSS
:rss {:main-opts ["-m" "loicb.server.rss"]}

;;---------- BUILD ----------
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.9.6" :git/sha "8e78bcc"}}
Expand Down
Loading

0 comments on commit f61b6fe

Please sign in to comment.