Skip to content

Commit

Permalink
[add] styling tables in docs [add] adding redirects to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Animenosekai committed Jun 25, 2022
1 parent 59d190e commit 063718e
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 7 deletions.
2 changes: 1 addition & 1 deletion website/components/ui/markdown/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const CodeBlock = ({ node, inline, className, children, ...props }) => {
<Lowlight
className="overflow-x-auto w-[80vw] text-[85%] my-4"
value={String(children).replace(/\n$/, '')}
language={common.includes(match[1]) ? match[1] : undefined}
language={common.includes((match && match[1])) ? match[1] : undefined}
inline={inline}
{...props}
/>
Expand Down
8 changes: 7 additions & 1 deletion website/components/ui/markdown/headings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const Heading3 = ({ node, level, children, key, ...props }) => {

export const Heading4 = ({ node, level, children, key, ...props }) => {
return <section id={headingLink(children.toString())}>
<h4 className="text-base font-normal mt-3 mb-1">{children}</h4>
<h4 className="text-base font-medium mt-3 mb-1">{children}</h4>
</section>
}

export const Heading5 = ({ node, level, children, key, ...props }) => {
return <section id={headingLink(children.toString())}>
<h5 className="text-base font-normal mt-3 mb-1">{children}</h5>
</section>
}
11 changes: 9 additions & 2 deletions website/components/ui/markdown/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Heading1, Heading2, Heading3, Heading4 } from "./headings";
import { Heading1, Heading2, Heading3, Heading4, Heading5 } from "./headings";
import { ListItem, OrderedList, UnorderedList } from "./lists";
import { Table, TableD, TableH, TableHead, TableR } from "./table";

import { CodeBlock } from "./code";

Expand All @@ -9,7 +10,13 @@ export const MarkdownComponent = {
h2: Heading2,
h3: Heading3,
h4: Heading4,
h5: Heading5,
li: ListItem,
ol: OrderedList,
ul: UnorderedList
ul: UnorderedList,
table: Table,
thead: TableHead,
tr: TableR,
th: TableH,
td: TableD
}
19 changes: 19 additions & 0 deletions website/components/ui/markdown/table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const Table = ({ node, children, key, ...props }) => {
return <table className="w-max max-w-full overflow-auto block">{children}</table>
}

export const TableHead = ({ node, children, key, ...props }) => {
return <thead>{children}</thead>
}

export const TableR = ({ node, isHeader, children, key, ...props }) => {
return <tr className="border-t-[1px] even:bg-[#f6f8fa]">{children}</tr>
}

export const TableH = ({ node, style, isHeader, children, key, ...props }) => {
return <th className="py-[6px] px-[13px] border-[1px]">{children}</th>
}

export const TableD = ({ node, style, isHeader, children, key, ...props }) => {
return <td className="py-[6px] px-[13px] border-[1px]">{children}</td>
}
4 changes: 4 additions & 0 deletions website/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const Configuration = {
request: {
host: process.env.NODE_ENV === "development" ? "http://127.0.0.1:5001" : "https://anise-translate.herokuapp.com"
},
repo: {
// branch: "website"
branch: "59d190ee0972ab8a0cb56c69c793063869f1ae5d"
}
}

Expand Down
11 changes: 9 additions & 2 deletions website/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
reactStrictMode: true,
async redirects() {
return [{
source: '/documentation',
destination: '/documentation/translatepy',
permanent: false,
}, ]
},
}

module.exports = nextConfig
module.exports = nextConfig
3 changes: 2 additions & 1 deletion website/pages/documentation/[...path].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react'

import Configuration from 'config'
import Link from 'next/link'
import { MarkdownComponent } from 'components/ui/markdown'
import type { NextPage } from 'next'
Expand Down Expand Up @@ -40,7 +41,7 @@ const Documentation: NextPage = () => {
if (!resultPath.endsWith(".md")) {
resultPath += "/README.md"
}
fetch(`https://cdn.jsdelivr.net/gh/Animenosekai/translate@website/docs/${encodeURIComponent(strings.name)}${resultPath}`)
fetch(`https://cdn.jsdelivr.net/gh/Animenosekai/translate@${encodeURIComponent(Configuration.repo.branch)}/docs/${encodeURIComponent(strings.name)}${resultPath}`)
.then(response => response.text())
.then(text => {
if (path.join("|") === __path__) {
Expand Down

1 comment on commit 063718e

@vercel
Copy link

@vercel vercel bot commented on 063718e Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.