blogit alternatives and similar packages
Based on the "Static Page Generation" category.
Alternatively, view blogit alternatives based on common mentions on social networks and blogs.
-
NimblePublisher
A minimal filesystem-based publishing engine with Markdown support and code highlighting -
pardall_markdown
DISCONTINUED. Reactive publishing framework, filesystem-based with support for Markdown, nested hierarchies, and instant content rebuilding. Written in Elixir.
CodeRabbit: AI Code Reviews for Developers
Do you think we are missing an alternative of blogit or a related project?
Popular Comparisons
README
Blogit
Blogit is a blog engine back-end written in Elixir. It turns a repository (by default git repository), containing markdown files into streams of blog posts, which can be queried. Blogit supports blog configuration in YAML, including blog title, path to custom styles and images, etc.
There is a front-end implementation in Phoenix, which uses Blogit - BlogitWeb. It can be forked and configured to use any repository to build custom blog.
The blog for the Sofia University Elixir course runs on Blogit.
Installation
It is available in Hex, so the package can be installed:
Add
blogit
to your list of dependencies inmix.exs
:def deps do [{:blogit, "~> 1.2"}] end
Ensure
blogit
is started before your application:def application do [applications: [:blogit]] end
Configuration
An example configuration for blogit is:
config :blogit,
repository_url: "https://github.com/ElixirCourse/blog.git",
polling: true, poll_interval: 300, languages: ~w(en bg de)
Possible settings are:
repository_url
|> Tells Blogit the location of the repository to use to build its contents.polling
|> Tells Blogit if it should poll the repository specified throughrepository_url
for changes. By default it istrue
.poll_interval
|> Used ifpolling
is set totrue
. The polling for changes will happen on this interval of seconds. By default it is10
seconds.repository_provider
|> Specified a specific implementation of the Blogit.RepositoryProvider behaviour. By default it usesBlogit.RepositoryProviders.Git
which works with git repositories and knows how to check for changes in them.configuration_file
|> Path to YAML file in the repository, which contains configuration for the blog. By default it isblog.yml
.languages
|> A list of language codes. By default it is["en"]
. The first language of the list is the default and primaty language. If there are alternative languages, if post source files are created in the folder<repo-root>/posts/<lang-code>
, the posts compiled from them are marked that are in the given language. They can be queried withBlogit.list_posts(language: "<lang-code>")
.max_lines_in_preview
|> The maximum lines to be used from the content of the original post source to generate its preview. The preview is generated from the beginning of the content and contains maximummax_lines_in_preview
lines. By default this value is10
.
Using these settings a custom blog can be created from whatever repository. It is not hard to write FTP repository provider or Ecto repository provider.
Usage
Blogit has a public interface which can be used to build a blog similar to BlogitWeb. When the application is configured and started, the following functions can be called:
Blogit.list_posts(options)
Returns a list of
Blogit.Models.Post.Meta
structs representing posts previews in the blog. The posts are sorted by their creation date, newest first.All the markdown files in the folder
<repo-root>/posts
will be transformed intoBlogit.Models.Post
structs and theircreated_at
meta field will be read using the configuredBlogit.RepositoryProvider
.Post previews can be skipped using the
from
option, which is0
by default. The size of the returned list is:infinity
by default (meaning "return all post previews"), but it can be changed with thesize
option to a number. By using these two options simple paging functionality can be implemented.Another supported option is
language
. It defaults to the default language (the first one in the configuredlanguages
list). A stream of post previews for the givenlanguage
will be returned.Examples:
# All post previews in the default language post_previews = Blogit.list_posts() # The first 5 post previews in the default language post_previews = Blogit.list_posts(size: 5) # The second 5 post previews in the default language post_previews = Blogit.list_posts(size: 5, from: 5) # All post previews in Bulgarian post_previews = Blogit.list_posts(language: "bg") # The second 5 post previews in Bulgarian post_previews = Blogit.list_posts(language: "bg", size: 5, from: 5)
Blogit.list_pinned(options)
Returns a list of tuples. Every such tuple has the unique name of a post as first element and its title as second. These tuples are sorted by the last updated date of the posts they represent.
All the markdown files in the source
posts
folder will be transformed intoBlogit.Models.Post
strucs and theirupdated_at
meta field will be read using the configuredBlogit.RepositoryProvider
.Pinned posts are posts which have specified
pinned: true
in their meta data.These are special posts which should be easy to find in the front-end implementation.
The only supported option is
language
. It defaults to the default language (the first one in the configuredlanguages
list). Pinned post tuples for the givenlanguage
will be returned.Examples:
# Pinned post tuples for the default language Blogit.list_pinned() # Pinned post tuples for posts in German Blogit.list_pinned(language: "de")
Blogit.filter_posts(filters, options)
Returns a list of
Blogit.Models.Post.Meta
structs, filtered by the givenfilters
.The first argument of the function is a map of filters. This map supports zero or more of the following keys:
- "author" - Used to filter posts by their
.meta.author
field. - "category" - Used to filter posts by their
.meta.category
field. - "tags" - Used to filter posts by their
.meta.tags
field. The value for this key should a string of comma separated tags ("one,two,three"
). - "year" - Used to filter posts by their
.meta.year
field. - "month" - Used to filter posts by their
.meta.month
field. - "q" - A query to filter posts by their content or title. Supports text in double quotes in order to search for phrases.
All these keys must be strings.
Filtered post previews can be skipped using the
from
option, which is0
by default. The size of the returned list is:infinity
by default (meaning "return all filtered post previews"), but it can be changed with thesize
option to a number. By using these two options simple paging functionality can be implemented.Another supported option is
language
. It defaults to the default language (the first one in the configuredlanguages
list). A stream of post previews, filtered by the givenfilters
for the givenlanguage
will be returned.Examples:
# All the post previews in the default language, filtered by the given `filters` filters = %{"q" => "OTP", "author" => "meddle", "tags" => "ab"} Blogit.filter_posts(filters) # The second two post previews in German, filtered by the given `filters` filters = %{"q" => "OTP", "author" => "meddle", "tags" => "ab"} Blogit.filter_posts(filters, language: "de", from: 2, size: 2)
- "author" - Used to filter posts by their
Blogit.posts_by_dates(options)
Returns a list of tuples of three elements from the given list of posts.
The first element of a tuple is a year. The second is a month number. The third is a counter - how many posts are created during that month and that year.
The tuples are sorted from the newest to the oldest, using the years and the months.
Can be used for implementing an easy-to-browse view component by years/months.
The only supported option is
language
. It defaults to the default language (the first one in the configuredlanguages
list). Statistics for the posts in the givenlanguage
will be returned.Examples:
# Statistics for the posts in the default language posts_by_date = Blogit.posts_by_dates() # [{2017, 6, 5}, {2017, 5, 1}, {2016, 5, 1}] # Statistics for the posts in Bulgarian posts_by_date = Blogit.posts_by_dates(language: "bg") # [{2017, 5, 1}, {2016, 5, 1}]
Blogit.post_by_name(name, options)
Returns a single post by its unique identifier - its
name
field. The name should be an atom. The result is in the form{:ok, post}
if a post with the givenname
exist for the given (or default) language. Thepost
element of that tuple is aBlogit.Models.Post
struct.Posts have unique names, usually constructed using the file path of their source markdown file in the repository.
If there is no post with the given
name
, the tuple{:error, "No post with name the-passed-name found."}
is returned.The only supported option is
language
. It defaults to the default language (the first one in the configuredlanguages
list). Post with the givenname
in the givenlanguage
will be returned if found.Examples:
# A post with the name `:otp`, written in the default language {:ok, post} = Blogit.post_by_name(:otp) IO.puts post.name # :otp IO.puts post.meta.author # The author of the post IO.puts post.raw # The source markdown of the post # A post with the name `:otp`, written in Bulgarian {:ok, post} = Blogit.post_by_name(:otp, language: "bg")
Blogit.configuration(options)
Retrieves the blog configuration. The configuration is in the form of a
Blogit.Models.Configuration
struct.It contains title and sub-title of the blog, path to logo or background image (or both), path to custom CSS file, etc..
The configuration is generated from an YAML file (by default blog.yml, stored in the root of the repository of the blog). This location can be configured through setting the
:configuration_file
key of the:blogit
configuration.The only supported option is
language
. It defaults to the default language (the first one in the configuredlanguages
list). Configuration for the givenlanguage
will be returned.Examples:
# The configuration of the blog for the default language Blogit.configuration() # The configuration for the German part of the blog Blogit.configuration(language: "de")
License
The license is standard MIT license, feel free to fork Blogit and do whatever you want with it. You can also contribute to it.
Contributions
Just fork the Blogit repository and create a PR. You can also create issues with features you wish we support. You can propose style changes on the code and additional tests.
All kinds of contributions are welcome!
How to create your own blog?
Blogit has a simple Phoenix front-end application : BlogitWeb.
Follow these steps to create your own blog (read more at BlogitWeb's README):
- Fork BlogitWeb project.
Modify its
config/prod.exs
configuration:config :blogit, repository_url: "<path-to-a-git-repository-with-your-posts>", polling: true, poll_interval: 300
Recompile the dependencies, so the configuration is updated:
mix deps.get mix deps.clean mix deps.compile
Deploy it somewhere.
BlogitWeb depends on
distillery
and has a little bash script in its root, calledbuild_release.sh
. Just run it and it will build a release. You can also run it like this :./build_release.sh --upgrade
in order to create updated release. Followdistillery
's notes when deploying.'BlogitWeb has a
Dockerfile.build
file which can be used to make a build inDocker
if you don't haveElixir
installed. It has aDockerfile
too so you can try it locally.There is a template
edeliver
configuration too.When it is deployed just add new markdown posts to your repository specified in the configuration and it will be published automatically.
Features to be implemented
- Pages (for example 'about me') and specific streams of posts, presented as pages.
- Slides. If we have a folder containing a specifically formated markdown (?) files, they could be turned into slides available on Blogit.
- Different front-ends for Blogit. Not only BlogtWeb. Also let's keep BlogitWeb up to date, tested and documented. For now it is a bit messy, but usable.
- Multiple source formats for posts, not only MARKDOWN.
- Additional repository providers.
Contact me
I'm Nikolay Tsvetinov (meddle) from elixir-lang.bg.
You can find me at:
*Note that all licence references and agreements mentioned in the blogit README section above
are relevant to that project's source code only.