Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs v2 #21

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Documentation Checks

on:
push:
branches:
- main
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
pull_request:
paths:
- 'docs/**'
- '.github/workflows/docs.yml'

jobs:
check_formatting:
runs-on: ubuntu-latest
name: Check Documentation Formatting

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './docs/package-lock.json'

- name: Install dependencies
working-directory: ./docs
run: npm ci

- name: Check formatting
working-directory: ./docs
run: npm run format:check
11 changes: 9 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ on:
push:
branches:
- main

paths-ignore:
- 'docs/**'
- '.github/workflows/docs.yml'
- '**.md'
pull_request:
paths-ignore:
- 'docs/**'
- '.github/workflows/docs.yml'
- '**.md'

jobs:
lint:
Expand All @@ -15,7 +22,7 @@ jobs:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions docs/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules
**/dist
**/cache
177 changes: 97 additions & 80 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineConfig } from "vitepress";
import { tabsMarkdownPlugin } from "vitepress-plugin-tabs";
import { defineConfig } from 'vitepress'
import { tabsMarkdownPlugin } from './vitepress-plugin-tabs/tabsMarkdownPlugin'

const title = "Inertia Rails";
const description = "Community documentation for Inertia.js Rails adapter";
const site = "https://inertia-rails.netlify.app";
const image = `${site}/og_image.jpg`;
const title = 'Inertia Rails'
const description = 'Community documentation for Inertia.js Rails adapter'
const site = 'https://inertia-rails.netlify.app'
const image = `${site}/og_image.jpg`

// https://vitepress.dev/reference/site-config
export default defineConfig({
Expand All @@ -13,124 +13,141 @@ export default defineConfig({

markdown: {
config(md) {
md.use(tabsMarkdownPlugin);
md.use(tabsMarkdownPlugin)
},
},

head: [
["link", { rel: "icon", href: "/favicon.ico", sizes: "32x32" }],
["link", { rel: "icon", href: "/icon.svg", type: "image/svg+xml" }],
['link', { rel: 'icon', href: '/favicon.ico', sizes: '32x32' }],
['link', { rel: 'icon', href: '/icon.svg', type: 'image/svg+xml' }],

["meta", { name: "twitter:card", content: "summary_large_image" }],
["meta", { name: "twitter:site", content: site }],
["meta", { name: "twitter:description", value: description }],
["meta", { name: "twitter:image", content: image }],
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['meta', { name: 'twitter:site', content: site }],
['meta', { name: 'twitter:description', value: description }],
['meta', { name: 'twitter:image', content: image }],

["meta", { property: "og:type", content: "website" }],
["meta", { property: "og:locale", content: "en_US" }],
["meta", { property: "og:site", content: site }],
["meta", { property: "og:site_name", content: title }],
["meta", { property: "og:image", content: image }],
["meta", { property: "og:description", content: description }],
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:locale', content: 'en_US' }],
['meta', { property: 'og:site', content: site }],
['meta', { property: 'og:site_name', content: title }],
['meta', { property: 'og:image', content: image }],
['meta', { property: 'og:description', content: description }],
],

themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: "Home", link: "/" },
{ text: "Guide", link: "/guide" },
{ text: "Cookbook", link: "/cookbook/integrating-shadcn-ui" },
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide' },
{ text: 'Cookbook', link: '/cookbook/integrating-shadcn-ui' },
{
text: "Links",
text: 'Links',
items: [
{ text: "Official Inertia.js docs", link: "https://inertiajs.com" },
{ text: 'Official Inertia.js docs', link: 'https://inertiajs.com' },
{
text: "Gems",
text: 'Gems',
items: [
{
text: "inertia_rails",
link: "https://github.com/inertiajs/inertia-rails",
text: 'inertia_rails',
link: 'https://github.com/inertiajs/inertia-rails',
},
{
text: "inertia_rails-contrib",
link: "https://github.com/skryukov/inertia_rails-contrib",
text: 'inertia_rails-contrib',
link: 'https://github.com/skryukov/inertia_rails-contrib',
},
],
},
],
},
],

logo: "/logo.svg",
logo: '/logo.svg',

sidebar: {
"/guide": [
'/guide': [
{
items: [
{ text: "Introduction", link: "/guide" },
{ text: "Demo app", link: "/guide/demo-application" },
{ text: 'Introduction', link: '/guide' },
{ text: 'Demo app', link: '/guide/demo-application' },
{ text: 'Upgrade guide', link: '/guide/upgrade-guide' },
],
},
{
text: "Installation",
text: 'Installation',
items: [
{ text: "Server-side", link: "/guide/server-side-setup" },
{ text: "Client-side", link: "/guide/client-side-setup" },
{ text: 'Server-side', link: '/guide/server-side-setup' },
{ text: 'Client-side', link: '/guide/client-side-setup' },
],
},
{
text: "Core concepts",
text: 'Core concepts',
items: [
{ text: "Who is it for", link: "/guide/who-is-it-for" },
{ text: "How it works", link: "/guide/how-it-works" },
{ text: "The protocol", link: "/guide/the-protocol" },
{ text: 'Who is it for', link: '/guide/who-is-it-for' },
{ text: 'How it works', link: '/guide/how-it-works' },
{ text: 'The protocol', link: '/guide/the-protocol' },
],
},
{
text: "The basics",
text: 'The basics',
items: [
{ text: "Pages", link: "/guide/pages" },
{ text: "Responses", link: "/guide/responses" },
{ text: "Redirects", link: "/guide/redirects" },
{ text: "Routing", link: "/guide/routing" },
{ text: "Title & meta", link: "/guide/title-and-meta" },
{ text: "Links", link: "/guide/links" },
{ text: "Manual visits", link: "/guide/manual-visits" },
{ text: "Forms", link: "/guide/forms" },
{ text: "File uploads", link: "/guide/file-uploads" },
{ text: "Validation", link: "/guide/validation" },
{ text: "Shared data", link: "/guide/shared-data" },
{ text: 'Pages', link: '/guide/pages' },
{ text: 'Responses', link: '/guide/responses' },
{ text: 'Redirects', link: '/guide/redirects' },
{ text: 'Routing', link: '/guide/routing' },
{ text: 'Title & meta', link: '/guide/title-and-meta' },
{ text: 'Links', link: '/guide/links' },
{ text: 'Manual visits', link: '/guide/manual-visits' },
{ text: 'Forms', link: '/guide/forms' },
{ text: 'File uploads', link: '/guide/file-uploads' },
{ text: 'Validation', link: '/guide/validation' },
],
},
{
text: "Advanced",
text: 'Data & Props',
items: [
{ text: "Events", link: "/guide/events" },
{ text: "Testing", link: "/guide/testing" },
{ text: "Partial reloads", link: "/guide/partial-reloads" },
{ text: "Scroll management", link: "/guide/scroll-management" },
{ text: "Authentication", link: "/guide/authentication" },
{ text: "Authorization", link: "/guide/authorization" },
{ text: "CSRF protection", link: "/guide/csrf-protection" },
{ text: "Error handling", link: "/guide/error-handling" },
{ text: "Asset versioning", link: "/guide/asset-versioning" },
{ text: "Progress indicators", link: "/guide/progress-indicators" },
{ text: "Remembering state", link: "/guide/remembering-state" },
{ text: "Code splitting", link: "/guide/code-splitting" },
{ text: 'Shared data', link: '/guide/shared-data' },
{ text: 'Partial reloads', link: '/guide/partial-reloads' },
{ text: 'Deferred props', link: '/guide/deferred-props' },
{ text: 'Polling', link: '/guide/polling' },
{ text: 'Prefetching', link: '/guide/prefetching' },
{ text: 'Load when visible', link: '/guide/load-when-visible' },
{ text: 'Merging props', link: '/guide/merging-props' },
{ text: 'Remembering state', link: '/guide/remembering-state' },
],
},
{
text: 'Security',
items: [
{ text: 'Authentication', link: '/guide/authentication' },
{ text: 'Authorization', link: '/guide/authorization' },
{ text: 'CSRF protection', link: '/guide/csrf-protection' },
{ text: 'History encryption', link: '/guide/history-encryption' },
],
},
{
text: 'Advanced',
items: [
{ text: 'Asset versioning', link: '/guide/asset-versioning' },
{ text: 'Code splitting', link: '/guide/code-splitting' },
{ text: 'Error handling', link: '/guide/error-handling' },
{ text: 'Events', link: '/guide/events' },
{ text: 'Progress indicators', link: '/guide/progress-indicators' },
{ text: 'Scroll management', link: '/guide/scroll-management' },
{
text: "Server-side rendering",
link: "/guide/server-side-rendering",
text: 'Server-side rendering',
link: '/guide/server-side-rendering',
},
{ text: 'Testing', link: '/guide/testing' },
],
},
],
"/cookbook": [
'/cookbook': [
{
items: [
{
text: "Integrations",
text: 'Integrations',
items: [
{ text: "shadcn/ui", link: "/cookbook/integrating-shadcn-ui" },
{ text: 'shadcn/ui', link: '/cookbook/integrating-shadcn-ui' },
],
},
],
Expand All @@ -139,24 +156,24 @@ export default defineConfig({
},

search: {
provider: "algolia",
provider: 'algolia',
options: {
appId: "NFLARHZ4Q4",
apiKey: "5e79b6038b027b5bb342ea5a31d0a2e8",
indexName: "inertia-rails",
appId: 'NFLARHZ4Q4',
apiKey: '5e79b6038b027b5bb342ea5a31d0a2e8',
indexName: 'inertia-rails',
},
},

editLink: {
pattern:
"https://github.com/skryukov/inertia_rails-contrib/edit/main/docs/:path",
text: "Edit this page on GitHub",
'https://github.com/skryukov/inertia_rails-contrib/edit/main/docs/:path',
text: 'Edit this page on GitHub',
},

socialLinks: [
{ icon: "github", link: "https://github.com/inertiajs/inertia-rails" },
{ icon: "x", link: "https://x.com/inertiajs" },
{ icon: "discord", link: "https://discord.gg/inertiajs" },
{ icon: 'github', link: 'https://github.com/inertiajs/inertia-rails' },
{ icon: 'x', link: 'https://x.com/inertiajs' },
{ icon: 'discord', link: 'https://discord.gg/inertiajs' },
],
},
});
})
24 changes: 12 additions & 12 deletions docs/.vitepress/theme/frameworksTabs.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
const localStorageKey = "vitepress:tabsSharedState";
const ls = typeof localStorage !== "undefined" ? localStorage : null;
const localStorageKey = 'vitepress:tabsSharedState'
const ls = typeof localStorage !== 'undefined' ? localStorage : null

const getLocalStorageValue = (): Record<string, string> => {
const rawValue = ls?.getItem(localStorageKey);
const rawValue = ls?.getItem(localStorageKey)
if (rawValue) {
try {
return JSON.parse(rawValue);
return JSON.parse(rawValue)
} catch {}
}
return {};
};
return {}
}

const setLocalStorageValue = (v: Record<string, string>) => {
if (!ls) return;
ls.setItem(localStorageKey, JSON.stringify(v));
};
if (!ls) return
ls.setItem(localStorageKey, JSON.stringify(v))
}

export const setupFrameworksTabs = () => {
const v = getLocalStorageValue();
const v = getLocalStorageValue()
if (!v.frameworks) {
setLocalStorageValue({ frameworks: "React" });
setLocalStorageValue({ frameworks: 'React' })
}
};
}
20 changes: 10 additions & 10 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// https://vitepress.dev/guide/custom-theme
import { h } from "vue";
import type { Theme } from "vitepress";
import DefaultTheme from "vitepress/theme";
import { enhanceAppWithTabs } from "vitepress-plugin-tabs/client";
import { setupFrameworksTabs } from "./frameworksTabs";
import "./style.css";
import type { Theme } from 'vitepress'
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
import DefaultTheme from 'vitepress/theme'
import { h } from 'vue'
import { setupFrameworksTabs } from './frameworksTabs'
import './style.css'

export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
});
})
},
enhanceApp({ app, router, siteData }) {
enhanceAppWithTabs(app);
enhanceAppWithTabs(app)
},
setup() {
setupFrameworksTabs();
setupFrameworksTabs()
},
} satisfies Theme;
} satisfies Theme
Loading
Loading