diff --git a/.gitignore b/.gitignore index e349bf1..b0f85da 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ build/ assets/ content/ layouts/ -*.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..c73fc0b --- /dev/null +++ b/README.md @@ -0,0 +1,122 @@ +Static site generator from reStructuredText files. + +# Usage + +Run: + +```shell +git clone https://git.nxhs.cloud/ge/blog.git && cd blog +python3 -m venv env +source env/bin/activate +pip install -r requirements.txt +mkdir -p {layouts,content,assets/css/pygments} +touch settings.toml content/my_page.rst layouts/{base,index,post}.j2 +make css default +``` + +Put in **settings.toml**: + +```toml +[site] +title = 'My site' +index_page_title = 'Home page' +datetime_format = '%d %b %Y' + +[build] +build_dir = 'build' +content_dir = 'content' +templates_dir = 'layouts' +assets_dir = 'assets' + +[pygments] +theme = 'default' + +[docutils] +``` + +Create basic Jinja2 templates. + +**layouts/base.j2**: + +```jinja2 + + + + + + + + + + +
+

+ {% if posts %} + {{ site_title }} + {% else %} + {{ site_title }} / {{ page_title }}

+ {% endif %} +

+
+
+ {% block content %}{% endblock %} +
+ + + +``` + +**layouts/index.j2**: + +```jinja2 +{% extends "base.j2" %} +{% block content %} + +
+ +
+ +{% endblock %} +``` + +**layouts/post.j2**: + +```jinja2 +{% extends "base.j2" %} +{% block content %} + +
+ {{ post | safe }} +
+ +{% endblock %} +``` + +Put in **content/my_page.rst**: + +```restructuredtext +:title: My first page +:date: 01 Jan 1970 + +============= +My first page +============= + +Hello, World! +``` + +Build site: + +``` +make +``` + +See HTML in build/ dir. Write your own CSS styles. diff --git a/README.rst b/README.rst deleted file mode 100644 index 77946c2..0000000 --- a/README.rst +++ /dev/null @@ -1,107 +0,0 @@ -Static site generator from reStructuredText files. - -Usage -===== - -Run:: - - git clone ttps://git.nxhs.cloud/ge/blog.git && cd blog - python3 -m venv env - source env/bin/activate - pip intall -r requirements.txt - mkdir -p {layouts,content,assets/css/pygments} - touch settings.toml content/my_page.rst layout/{base,index,post}.j2 - make css default - -Put in settings.toml:: - - [site] - title = 'My site' - index_page_title = 'Home page' - datetime_format = '%d %b %Y' - - [build] - build_dir = 'build' - content_dir = 'content' - templates_dir = 'layouts' - assets_dir = 'assets' - - [pygments] - theme = 'default' - -Create basic Jinja2 templates. - -base.j2:: - - - - - - - - - - - -
-

- {% if posts %} - {{ site_title }} - {% else %} - {{ site_title }} / {{ page_title }}

- {% endif %} -

-
-
- {% block content %}{% endblock %} -
-
-
- - - -index.j2:: - - {% extends "base.j2" %} - {% block content %} - -
-
    - {% for post in posts %} -
  • - {{post['title'] }} - — {{ post['date'] }} -
  • - {% endfor %} -
-
- - {% endblock %} - -post.j2:: - - {% extends "base.j2" %} - {% block content %} - -
- {{ post | safe }} -
- - {% endblock %} - -Put in content/my_page.rst:: - - :title: My first page - :date: 01 Jan 1970 - - ============= - My first page - ============= - - Hello, World! - -Build site:: - - make - -See HTML in build/ dir. Write your own CSS styles. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f0fef09 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +docutils==0.17.1 +Jinja2==3.1.2 +Pygments==2.12.0 +toml==0.10.2