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 route cmd #55

Merged
merged 6 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ target
build
tailwind-dev.css
.DS_STORE
.vscode
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/rapid-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rapid-cli"
version = "0.5.8"
version = "0.5.9"
edition = "2021"
description = "The CLI tool for the Rapid framework"
repository = "https://github.com/DarrenBaldwin07/rapid"
Expand Down
18 changes: 18 additions & 0 deletions crates/rapid-cli/src/commands/routes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use super::RapidCommand;
use crate::{cli::Config, tui::logo};
use clap::{ArgMatches, Command};

// `rapid routes` command for showing all the route rust files and they map to in url form
pub struct Routes {}

impl RapidCommand for Routes {
fn cmd() -> clap::Command {
Command::new("routes").about("Show all the routes in your rapid project!")
}

fn execute(_: &Config, args: &ArgMatches) -> Result<(), crate::cli::CliError<'static>> {
println!("{}", logo());
println!("> Welcome to RAPID templates");
Ok(())
}
}
2 changes: 1 addition & 1 deletion crates/rapid-cli/templates/nextjs/Cargo__toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
futures-util = "0.3.28"
include_dir = "0.7.3"
rapid-web = "0.4.6"
rapid-web = "0.4.7"

# Rapid binary
[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion crates/rapid-cli/templates/remix-without-clerk/Cargo__toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
futures-util = "0.3.28"
include_dir = "0.7.3"
rapid-web = "0.4.5"
rapid-web = "0.4.7"

# Rapid binary
[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion crates/rapid-cli/templates/remix/Cargo__toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
futures-util = "0.3.28"
include_dir = "0.7.3"
rapid-web = "0.4.6"
rapid-web = "0.4.7"

# Rapid binary
[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion crates/rapid-ssr/src/polyfills/text_encoder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO: check to make sure this is not still an issue with react + TS (it could have recently been fixed but was still an issue in react18.0.0)
// TODO: check to make sure this is not still an issue with react + TS (it could have recently been fixed but was still an issue as of react18.0.0)
lazy_static! {
pub static ref POLYFILL: String = {
let mut polyfill = String::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/rapid-web/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rapid-web"
version = "0.4.6"
version = "0.4.7"
edition = "2021"
description = "A simple Rust server for the Rapid framework."
repository = "https://github.com/DarrenBaldwin07/rapid"
Expand Down
2 changes: 1 addition & 1 deletion crates/rapid-web/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl RapidServer {

/// A stock re-export of the actix-web "App::new()" router with a few extras
/// This router does not support type-safe file based routing
/// Note: to experience the full capabilities of rapid-web, we recommend useing the RapidServer::fs_router function
/// Note: to experience the full capabilities of rapid-web, we recommend using the RapidServer::fs_router function
pub fn router(
cors: Option<Cors>,
log_type: Option<RapidLogger>,
Expand Down
2 changes: 1 addition & 1 deletion crates/rapid-web/src/shift/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn convert_primitive(rust_primitive: &Type) -> TypescriptType {
"char" => TypescriptType::new("string".to_string(), false),
"str" => TypescriptType::new("string".to_string(), false),
"String" => TypescriptType::new("string".to_string(), false),
"Value" => TypescriptType::new("string".to_string(), false),
"Value" => TypescriptType::new("any".to_string(), false),
"NaiveDateTime" => TypescriptType::new("Date".to_string(), false),
"DateTime" => TypescriptType::new("Date".to_string(), false),
"Uuid" => TypescriptType::new("string".to_string(), false),
Expand Down
2 changes: 1 addition & 1 deletion crates/rapid-web/src/shift/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub fn get_output_type_alias(handler_source: &str) -> TypescriptType {
/// Function for checking if a rapid route path is dynamic (example: "/route/todo/_id_" -- this route is dynamic because it has a "_id_" substring)
pub fn is_dynamic_route(str: &str) -> bool {
// Check for a regex match for a substring similar to "_anythingInHere_"
let regex = regex::Regex::new(r"^_[^_]+_$").unwrap();
let regex = regex::Regex::new(r"_.*?_").unwrap();
regex.is_match(str)
}

Expand Down
20 changes: 10 additions & 10 deletions docs/landing/app/components/DocsLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const DocsLinks = () => {
</Text>
<div className='z-10 flex flex-col gap-2 border-l-[0.5px] border-[#222222]'>
<NavLink
to='/docs/introduction'
to='/docs/introduction/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -21,7 +21,7 @@ const DocsLinks = () => {
<Text styles='exclude-from-markdown'>Introduction</Text>
</NavLink>
<NavLink
to='/docs/quickstart'
to='/docs/quickstart/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -31,7 +31,7 @@ const DocsLinks = () => {
<Text styles='exclude-from-markdown'>Quickstart</Text>
</NavLink>
<NavLink
to='/docs/demo-app'
to='/docs/demo-app/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -46,7 +46,7 @@ const DocsLinks = () => {
<Text styles='gradient-text uppercase text-xs'>Server</Text>
<div className='z-10 flex flex-col gap-2 border-l-[0.5px] border-[#222222]'>
<NavLink
to='/docs/route-handlers'
to='/docs/route-handlers/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -58,7 +58,7 @@ const DocsLinks = () => {
</Text>
</NavLink>
<NavLink
to='/docs/middleware'
to='/docs/middleware/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -68,7 +68,7 @@ const DocsLinks = () => {
<Text styles='exclude-from-markdown'>Middleware</Text>
</NavLink>
<NavLink
to='/docs/type-safety'
to='/docs/type-safety/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -78,7 +78,7 @@ const DocsLinks = () => {
<Text styles='exclude-from-markdown'>Type Safety</Text>
</NavLink>
<NavLink
to='/docs/rapid-config'
to='/docs/rapid-config/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -95,7 +95,7 @@ const DocsLinks = () => {
<Text styles='gradient-text uppercase text-xs'>Client</Text>
<div className='z-10 flex flex-col gap-2 border-l-[0.5px] border-[#222222]'>
<NavLink
to='/docs/client/vanilla'
to='/docs/client/vanilla/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -105,7 +105,7 @@ const DocsLinks = () => {
<Text styles='exclude-from-markdown'>Vanilla</Text>
</NavLink>
<NavLink
to='/docs/client/remix'
to='/docs/client/remix/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand All @@ -115,7 +115,7 @@ const DocsLinks = () => {
<Text styles='exclude-from-markdown'>Remix</Text>
</NavLink>
<NavLink
to='/docs/client/nextjs'
to='/docs/client/nextjs/doc'
className={({ isActive }) =>
`text-docsText exclude-from-markdown z-10 border-l-2 border-transparent pl-4 transition-all duration-100 ease-in-out hover:text-white ${
isActive && 'border-l-mainBlue text-white'
Expand Down
2 changes: 1 addition & 1 deletion docs/landing/app/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const docsSetup = (routeName: string, request: Request) => {
url.pathname = `/docs/${routeName}`;
}

const routes = url.pathname.split('/').filter(Boolean);
const routes = url.pathname.split('/').filter(Boolean)

return json({
routes,
Expand Down
1 change: 1 addition & 0 deletions docs/landing/app/routes/docs.demo-app.doc.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Coming soon...
15 changes: 6 additions & 9 deletions docs/landing/app/routes/docs.demo-app.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
import React from 'react';
import { json } from '@remix-run/node';
import { docsSetup } from '~/helpers';
import type { LoaderFunction } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
import { Outlet, useLoaderData } from '@remix-run/react';
import { BreadCrumb } from '~/components/BreadCrumb';

interface LoaderOutput {
routes: string[];
}

export const loader: LoaderFunction = ({ request }) => {
const url = new URL(request.url);
const routes = url.pathname.split('/').filter(Boolean);

return json({
routes,
});
return docsSetup("demo-app", request);
};

const DocsDemoApp = () => {
const data = useLoaderData<LoaderOutput>();
return (
<div>
<BreadCrumb routes={data.routes} />
<div className='text-white'>Coming soon...</div>
<div className='mt-12 w-full text-white'>
<Outlet />
</div>
</div>
);
};
Expand Down
1 change: 1 addition & 0 deletions docs/landing/app/routes/docs.route-handlers.doc.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Hello world
46 changes: 46 additions & 0 deletions docs/landing/app/routes/docs.route-handlers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import type { LoaderFunction, LinksFunction } from '@remix-run/node';
import { useLoaderData, Outlet } from '@remix-run/react';
import { Heading } from '@rapid-web/ui';
import { BreadCrumb } from '~/components/BreadCrumb';
import { docsSetup } from '~/helpers';
import prism from '../styles/prism.css';
import styles from '../styles/markdown.css';

interface LoaderOutput {
routes: string[];
}

export const links: LinksFunction = () => {
return [
{
rel: 'stylesheet',
href: styles,
},
{
rel: 'stylesheet',
href: prism,
},
];
};

export const loader: LoaderFunction = ({ request }) => {
return docsSetup("route-handlers", request);
};

const RouteHandlers = () => {
const data = useLoaderData<LoaderOutput>();
return (
<div>
<BreadCrumb routes={data.routes} />
<Heading styles='exclude-from-markdown text-white text-5xl font-bold'>
Route handlers
</Heading>
<div className='mt-12 w-full text-white'>
<Outlet />
</div>
</div>
);
};

export default RouteHandlers;
Loading