From b083bb5dc8a94f109041256acb24b8aff8bddb5f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 23 Jun 2024 20:28:46 +0200 Subject: [PATCH] docs: added footer --- README.footer.md | 3 +++ README.md | 8 ++++++-- lua/build.lua | 51 +++++++++++++++++++++++++++--------------------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/README.footer.md b/README.footer.md index e69de29..038bb27 100644 --- a/README.footer.md +++ b/README.footer.md @@ -0,0 +1,3 @@ +## 🚀 Getting Started + +Check the [documentation website](https://lazy.folke.io/) for more information. diff --git a/README.md b/README.md index ade77de..a950b94 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ -# 🚀 Getting Started + **lazy.nvim** is a modern plugin manager for Neovim. @@ -60,4 +60,8 @@ - Neovim >= **0.8.0** (needs to be built with **LuaJIT**) - Git >= **2.19.0** (for partial clones support) -- a [Nerd Font](https://www.nerdfonts.com/) **_(optional)_** \ No newline at end of file +- a [Nerd Font](https://www.nerdfonts.com/) **_(optional)_** + +## 🚀 Getting Started + +Check the [documentation website](https://lazy.folke.io/) for more information. \ No newline at end of file diff --git a/lua/build.lua b/lua/build.lua index 300a939..c54c254 100644 --- a/lua/build.lua +++ b/lua/build.lua @@ -86,7 +86,9 @@ end ---@param readme? string ---@param mds? string[] -function M.readme(readme, mds) +---@param transform? fun(s:string):string +function M.readme(readme, mds, transform) + local is_sorted = mds ~= nil readme = readme or "README.md" mds = mds or vim.fs.find(function(name, path) @@ -101,27 +103,29 @@ function M.readme(readme, mds) "usage", "developers", } - table.sort(mds, function(a, b) - local aa = 0 - local bb = 0 - for i, name in ipairs(sorters) do - if a:match(name) then - aa = i + if not is_sorted then + table.sort(mds, function(a, b) + local aa = 0 + local bb = 0 + for i, name in ipairs(sorters) do + if a:match(name) then + aa = i + end + if b:match(name) then + bb = i + end end - if b:match(name) then - bb = i + if aa == bb then + if a:match("index") then + return true + elseif b:match("index") then + return false + end + return a < b end - end - if aa == bb then - if a:match("index") then - return true - elseif b:match("index") then - return false - end - return a < b - end - return aa < bb - end) + return aa < bb + end) + end local text = "" for _, md in ipairs(mds) do local _, level = md:gsub("/", "") @@ -129,6 +133,7 @@ function M.readme(readme, mds) if md:match("index") then level = level - 1 end + level = math.max(0, level) local t = Util.read_file(md) .. "\n\n" -- remove frontmatter t = t:gsub("^%-%-%-.-%-%-%-\n", "") @@ -151,6 +156,7 @@ function M.readme(readme, mds) text = text .. "\n\n" .. vim.trim(t) end text = vim.trim(text) + text = transform and transform(text) or text Util.write_file(readme, text) end @@ -159,9 +165,10 @@ function M.update() M.readme("README.md", { "README.header.md", "docs/intro.md", - -- "docs/installation.mdx", "README.footer.md", - }) + }, function(s) + return s:gsub("\n# 🚀 Getting Started", "\n") + end) M.themes() M.docs() vim.cmd.checktime()