Skip to content

Commit

Permalink
Merge pull request #341 from numtide/feat/versioned-docs
Browse files Browse the repository at this point in the history
feat: simple versioned docs
  • Loading branch information
brianmcgee authored Jul 5, 2024
2 parents 4cc7e00 + d9f413a commit 9bbc49a
Show file tree
Hide file tree
Showing 27 changed files with 1,878 additions and 416 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ This project is still pretty new. Down the line we also want to add support for:

## Contributing

All contributions are welcome! We try to keep the project simple and focused. Please refer to the [Contributing](./docs/contributing.md)
All contributions are welcome! We try to keep the project simple and focused. Please refer to the [Contributing](docs/contributing.md)
guidelines for more information.

## Moving from Rust To Go
Expand Down
55 changes: 41 additions & 14 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
import { defineConfig } from 'vitepress'
import defineVersionedConfig from "vitepress-versioning-plugin";
import DefaultTheme from "vitepress/theme";


// manually specifying the versioned sidebars to preserve isActive linking, I just couldn't seem to get it to
// work properly with the plugin

const sidebar = {
"/": [
{ text: 'Motivation', link: '/about' },
{ text: 'Quick Start', link: '/quick-start' },
{ text: 'Install Treefmt', link: '/install' },
{ text: 'Configure Treefmt', link: '/configure' },
{ text: 'Run Treefmt', link: '/usage' },
{ text: 'Formatter Spec', link: '/formatter-spec' },
{ text: 'Contributing', link: '/contributing' },
{ text: 'FAQ', link: '/faq' },
]
}

// static version list, KISS
const versions = ["v2.0.1", "v2.0.2"]

versions.forEach(version => {
sidebar[`/${version}/`] = sidebar["/"].map(({ text, link }) => ({ text, link: `/${version}${link}`}))
})

console.log("sidebar", sidebar)

// https://vitepress.dev/reference/site-config
export default defineConfig({
export default defineVersionedConfig({
base: '/',

title: "Treefmt",
Expand All @@ -11,26 +39,25 @@ export default defineConfig({
['link', { rel: 'icon', href: '/logo.png' }],
],

cleanUrls: true,

versioning: {
latestVersion: "main",
},

themeConfig: {

logo: '/logo.svg',

// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
{ text: 'Quick Start', link: '/quick-start' }
{ text: 'Home', link: './' },
{ text: 'Quick Start', link: './quick-start' }
],

sidebar: [
{ text: 'Motivation', link: '/about' },
{ text: 'Quick Start', link: '/quick-start' },
{ text: 'Install Treefmt', link: '/install' },
{ text: 'Configure Treefmt', link: '/configure' },
{ text: 'Run Treefmt', link: '/usage' },
{ text: 'Formatter Spec', link: '/formatter-spec' },
{ text: 'Contributing', link: '/contributing' },
{ text: 'FAQ', link: '/faq' },
],
// manually specifying the versioned sidebars to preserve isActive linking, and I just couldn't seem to get it to
// work properly
sidebar,

socialLinks: [
{ icon: 'github', link: 'https://github.com/numtide/treefmt' }
Expand All @@ -41,4 +68,4 @@ export default defineConfig({
copyright: "Copyright © Numtide & Contributors"
}
}
})
}, __dirname)
4 changes: 2 additions & 2 deletions docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ The tool can be invoked manually or integrated into your CI. There's currently n

As a next step, learn how to [install] and [run] `treefmt`.

[install]: install
[run]: usage
[install]: install.md
[run]: usage.md
2 changes: 1 addition & 1 deletion docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ To find examples, take a look at <https://github.com/numtide/treefmt-nix/tree/ma

If you are a Nix user, you might also like <https://github.com/numtide/treefmt-nix>, which uses Nix to pull in the right formatter package and seamlessly integrates both together.

[spec]: formatter-spec
[spec]: formatter-spec.md
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ hero:
actions:
- theme: brand
text: Quick Start
link: /quick-start
link: ./quick-start
- theme: alt
text: More Info
link: /about
link: ./about

features:
- icon:
Expand Down
Loading

0 comments on commit 9bbc49a

Please sign in to comment.