Skip to content

Commit

Permalink
Add the ability to pull in docs from valkey-doc (valkey-io#22)
Browse files Browse the repository at this point in the history
* adds support for pulling in valkey-docs

Signed-off-by: Kyle J. Davis <[email protected]>

* one more change to layout

Signed-off-by: Kyle J. Davis <[email protected]>

---------

Signed-off-by: Kyle J. Davis <[email protected]>
  • Loading branch information
stockholmux authored Apr 10, 2024
1 parent d2a0899 commit 19d2253
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
mkdir _data/commands _includes/commands
ln -s $(pwd)/_submodules/valkey/src/commands $(pwd)/_data/commands/latest
ln -s $(pwd)/_submodules/valkey-doc/commands $(pwd)/_includes/commands/latest
ln -s $(pwd)/_submodules/valkey-doc/docs $(pwd)/_includes/docs
- name: Setup Ruby
uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ _site
vendor
.DS_Store
/_data/commands/
/_includes/commands/
/_includes/commands/
/_includes/docs/
1 change: 1 addition & 0 deletions _includes/docs
29 changes: 29 additions & 0 deletions _layouts/doc-import.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
layout: default
---
{%- assign primary_title = page.primary_title -%}
{%- comment -%}
This template pulls in the file from `source` in the front matter.

It detects if the script starts with front matter (delimited by `---`) by splitting and looking for the delimiter at the start of the file.
If the delimter is detected at the top of the file, it skips the the 3rd (zero based: 2) element and iterates over the remain sections.
If there delmiter is not detected (no front matter) it swallows the the whole file and markdownify's it.

{%- endcomment -%}
{%- capture md -%}{% include {{ page.source }} %}{%- endcapture -%}
{%- assign stripped_front_matter = md | split: "---" -%}
{%- include page_title.html -%}
<div class="width-limiter">
<main class="container">
{%- if stripped_front_matter[0].size == 0 -%}
{%- for item in stripped_front_matter offset:2 -%}
{{ item | markdownify }}
{%- if forloop.last == false -%}
<hr />
{%- endif -%}
{%- endfor -%}
{%- else -%}
{{ md | markdownify }}
{%- endif -%}
</main>
</div>
5 changes: 5 additions & 0 deletions docs/management/persistence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: doc-import
primary_title: Persistence
source: "/docs/management/persistence.md"
---

0 comments on commit 19d2253

Please sign in to comment.