This commit is contained in:
amirhouieh 2022-04-11 19:15:04 +02:00
parent 5052306a9c
commit 440de02913
19 changed files with 2728 additions and 32 deletions

View File

@ -0,0 +1,12 @@
import {FC} from "react";
import ReactMarkdown from "react-markdown";
interface IProps{
contentMD: string;
}
export const DefaultMarkdownBody: FC<IProps> = ({contentMD}) => (
<ReactMarkdown remarkPlugins={[]}>
{contentMD}
</ReactMarkdown>
)

11
components/Sidebar.tsx Normal file
View File

@ -0,0 +1,11 @@
import {FC} from "react";
interface IProps{}
export const Sidebar: FC<IProps> = (props) => {
return (
<div>
{JSON.stringify({})}
</div>
)
}

View File

@ -0,0 +1,7 @@
import {FC} from "react";
export const ThemeProvider: FC<any> = ({children}) => (
<>
{children}
</>
)

2
configs/defaults.ts Normal file
View File

@ -0,0 +1,2 @@
export const DOCS_DIR_NAME = "docs";

View File

@ -0,0 +1,7 @@
import preval from 'next-plugin-preval';
async function getData() {
return { items: [{link: "s/s/s/s"}]}
}
export default preval(getData());

56
docs/a/1 xY -x.md Normal file
View File

@ -0,0 +1,56 @@
# Ora dictis laevi sinus
## Binominis horrescere regnumque quem odoribus
Lorem markdownum minister fugerent, illis canat *erat*, contraque. Quod figit
vicisti atricolor negant; *patris alis respicit*, hac atque forte Thespiades
capillis!
ethernet(non(box_lte_webcam - 3), internet_bespoke_file, 57);
dialog(burn_e_ipv, daemonReal);
if (officeUat.wiDma.arp_printer_serp(binaryBalanceRup, tag)) {
cd *= case.logic_web_heat(flashDrive.boot_quicktime(4), -3);
dvdHorseProcess += -2;
keywords(operating_gigabit_raster);
}
var autoresponder = bezel_open_ip(99931, thumbnail_simplex_repository(
debugger_yobibyte_hertz, cardName)) * 4;
Solus comas, fidesque subdidit, igni, spatio contigerant deae fixo ferrum quae
Talia cumque, [sit est](http://www.velletin.io/aliquis). Est adempta Marte
concipit agrestes, sine est cuspis, simillimus nam, hunc. In **humo ductus
aliae** et aliud aequora haustum radios, Aiax ipsa. Nec et domos, vitasset
recesserat perpetuoque narravere semper omnipotens omnes pendentia dabitur
recurvo flamine praeter fiunt *eripuit superest* iaculum.
## Stare concita coloni lanae nisi que etiam
Lupi sed; quaterque teneros in nebulas [colla passus
undamque](http://www.quattuor-versuta.io/)? Quod queri, duce autem, ferae nympha
pater? Cassiope Echionides voces simus tamen spectacula cecidere metu moveri.
Donec virgo, citharaque et nympham, sed contigerat in? Nunc margine Atque, omne
humi, et ulmo utilis.
> Timidas pia cubilia utque, nec haec tandem, coortis cohibentur petit viribus.
> Que ambo alterius curvis **me data**. Coniunx spectantem, oris aula altae
> Delphos: nec ter Olympi postquam, contingere, est avibus, nimiumque lacrimae.
> Genitore vitae labore Aegaeo. Sua videri turbatis possim dixit novissima
> quamquam caecaque fratre marmore novoque.
Quem **disponunt** nympha: receptis! Specus omnes via repetitum mediis moderatus
[aliquem pennis](http://marte.io/crederein), vittam
[ignes](http://www.quater-ponentem.net/concidit-refert), modo.
**Attritas sole** gelidaeque mora genero per positasque profectu, qui. Quamquam
senemque, umbras eras *velocibus relictas* madescit marmore undas artes incaluit
me agros magni nec. Tolerare nec incursat luctus,
[Sabina](http://pacis.com/viae) aether caede manu, dis sunt vulnus dixi
Peliaeque, est traxit et ego. Facundia advertitur acies poscit exilio illic
excutit iactat, componar et arma et Lyciae capillos fugit fuit coniectum me.
Oculis dum est agnovere utilis Lernaeae, primos: quasque ubi miserabile in
mollis ipsa iubet petunt. Gemitus doli liquidum radice **lacrimisque herbas
terque** decrescunt vocatus aperti fuit tanto Silenus teloque: tenore rimas,
subit. Super luctus; manat est direpta superis, oras anxia silet. Uvis fuit
minorem maius, suum copia qui cum sub meae mitis, flagrant ad locum rabiem.
Concepit favilla huius animo est nullis gerebam videre?

58
docs/foo bar.md Normal file
View File

@ -0,0 +1,58 @@
# Copia pedes accipe vestigia carinae campis ede
## Medusaeo doctas lanient
Lorem markdownum, repetendus *in ducar* dextra est illi inmittitur et vel
tellure perde adest exsistunt. Illos laevisque *veniam* naufragus finis omnes
tua. Posituro nec humi ferre suadent accessit iamque ille furta ille! Atrides
garrula tetenderat et suis [illi abest](http://tota.net/cuperet-precibus) dici
ille parte cruento pulchra extento hora tumidus! Tantum a remotis Aurorae, quam
meorum?
- Tua prona ubi
- Ureris enim Cipe
- Per Scythicae bellare Hectora
- Litus esse
- Naribus Pelasgi et cur erat
Cereremque brevissimus ferro dixit ignes et turba referam tinctis dabimus ferit,
non flenti dedit, ore. Putetis villisque poscenti Osiris, datis **pulsat
scripsi**, clamat. Indis nostra tibi pressa est volanti parta. Ubi longo pro,
est aequorei detis, squamea pennis, stamen tamen? Arbore non lumina bracchia et
ipse sit, que nolim ipse flectit nulli dixit, deas nec nec et.
## Auxiliaribus ante
In proavos attoniti potestas, tum cornua traxit saepe. Meae erat ardet, poscenti
ulciscere multis hunc **redeunt cum** desiluit ille. Enim Pelasgi,
[oris](http://festum.io/inme), facinus, rite collocat, tota sua considere
geratis! Non mandere nemus.
- Efflant summum incaluit parvae neve unus trepidantes
- Convocat qui huic arcus undae hospitiique
- In induco
## Ipso iamque gloria nubila haud erat oculosque
Non dixerat ille circumfususque molliet quae profatur iunxit, in huic per,
adhuc, perque. Corpora sermonibus omnes, in nullaque recidendum perstat hanc,
praefractam quercu! Matris inter **instruitur perque** rediit caelicolae lucem,
diuque haec Aesonides **vestem dicere**, mea Troas et aqua duo! Deprendere
perstat unus cohibentem *deceptus* intexere et caelo famaque differt miraris,
eadem amplectitur.
var rpcSwipeBalance = drive;
if (parity_vdu - 4 + ircTelnet(drive, pipeline,
suffix_multiprocessing_honeypot)) {
install = queryWeb.bankFormula(ibmUgc + folder_it_osd, 94);
} else {
dualFunctionWins(kindle_telecommunications);
}
bmp += wi_viral(5, dslam_file(web(isoSubnet, graphicsFileBittorrent,
system)), surge);
sku_gigo_internic(gigahertz_point(metalSmtpComputing), cybercrime(-1, 5) -
firewallFontMemory, pptp.bezelMatrix(infotainment +
piconetAndJavascript, storageMpeg));
*Nescio grave* sit, ibi libera pedes, ex quondam. Tellus nomine, aut rotave,
ultima inde sacer Carmina datque Numici, barba

54
docs/test.md Normal file
View File

@ -0,0 +1,54 @@
# Saepe ne iura
## Si Libys transformat fuerat dederatque mergor
Lorem markdownum Euboico quis si hac aemulus, corporis intus; illi times
[mercede](http://quamvis.org/indeproxima.html). Hunc nato conclamat Pulchrior
quo. Qui tandem Venus, inque quos urbe durasse bracchia suo. Pedibusque de
nocuisse se verbere idque; ait linguae honore, via habet arbore errare. Erat ubi
dum regna sceleri: meus obsidis felix undas adopertaque ortu.
1. Convaluit esse vipereasque tibi fortis sponte
2. Partibus tendentem poenam sumpsisse ab nisi
3. Limina quodcunque saepe cum bracchia patremque tale
4. Credidit in auras murum
Dis robora animi mutatur est oscula denique spatiosi intus qui quid conveniunt,
munera erunt addit nova radiare. Quo pallam munus loco, dea summo ratis herculis
patulos femina *cuius*. Parce quique! In voce nota fide quam calido ut vidit
habes Cythno.
## Quod per
Differt intrat purpura: habitandae sic! Aures Dulichiae, exspectatus felicia
pavent intellecta ibat aspicis volucres et per.
> Nolle cortice fatisque, mole patris visibus superare agitata serpere
> spectantem. Funera loca mihi sed [urnam
> ulterius](http://tectus.net/additisveniam) sunt Peleu soluto; Augusto via.
> Tibi vix et nec sua poma accingitur; ipsas culpam cornus: paludes Tereus!
> Veterem tamque per invidia sensit luctus, quid superata fuerat Antigonen
> numquam **naides ministri iure** placato dubito genitor avertens et. Pomo
> surgit et et esset et modo.
## Mitia prospectet fugit vel tutaeque abiit opus
Ira ducum, requiescit conatur **occupat sacros adigitque** oculos fontem.
Ferventibus pretium cuius. Cum tineae vertere celebrandaque, hoc quod tibi *quid
auctor dixerat*, sua.
Vulnere orbem ad decipiet ultra miraturus legit sed armo
[habebant](http://nomine-illa.io/non-qua.php)! Et rumpunt ferro est fetum, in
est expellitque lateat! Aprica fundebat contigit Byblis tenuissimus auctor
caede, et alis duro.
Flexit vineta Chrysenque vineta simul quod necem Iasonis tantaeque robustior
ille indicat naides diligitur sublimia fueramque vel. Nomen est in sed praeterit
veras tempora, Iove hausta? Deos ait arbor, cum acutae erat valent horruit, Qui
in Quirini gener servare *sperando* Dodonaeo morari, sub.
Causa quos, mox, conplexibus sive quodque pectora: longis confessus orbi
resupina ossibus aera concilium tuque. Vulnus flumina. Prima ut Phineus anum
cornibus sentite tonitribus super. Quae ait via Troius numine nec regia ossaque
intellege animo [qui caecae](http://oditradiis.com/) motamque, erat **colubras
dicta** dies.

View File

@ -1,6 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
const createNextPluginPreval = require('next-plugin-preval/config');
const withNextPluginPreval = createNextPluginPreval();
const nextConfig = withNextPluginPreval({
reactStrictMode: true,
}
})
module.exports = nextConfig

View File

@ -9,9 +9,14 @@
"lint": "next lint"
},
"dependencies": {
"@sindresorhus/slugify": "^2.1.0",
"fast-glob": "^3.2.11",
"gray-matter": "^4.0.3",
"next": "12.1.4",
"next-plugin-preval": "^1.2.4",
"react": "18.0.0",
"react-dom": "18.0.0"
"react-dom": "18.0.0",
"react-markdown": "^8.0.2"
},
"devDependencies": {
"@types/node": "17.0.23",

25
pages/[...path].tsx Normal file
View File

@ -0,0 +1,25 @@
import {GetStaticPaths, GetStaticProps, NextPage} from "next";
import {DefaultTemplate_Markdown} from "../templates/DefaultTemplate";
import {IPagePropsMarkdown, IRouteParamsMarkdown} from "../types/data.types";
import {markdownDataUtils} from "../utils/data-utils/utils.data.local-md";
import {DOCS_DIR_NAME} from "../configs/defaults";
const DefaultPage: NextPage<IPagePropsMarkdown> = ({markdown}) => {
return (
<DefaultTemplate_Markdown markdown={markdown}>
<div>VIDEO</div>
</DefaultTemplate_Markdown>
)
}
export const getStaticPaths: GetStaticPaths<IRouteParamsMarkdown> = async () => {
return markdownDataUtils.getStaticPaths(DOCS_DIR_NAME);
}
export const getStaticProps: GetStaticProps<IPagePropsMarkdown, IRouteParamsMarkdown, any> = async (context) => {
return markdownDataUtils.getStaticProps(DOCS_DIR_NAME, context);
}
export default DefaultPage

View File

@ -1,7 +1,20 @@
import type { AppProps } from 'next/app'
import type {AppProps} from 'next/app'
import {ThemeProvider} from "../components/mocked-design-system"
import {PageComponent} from "../types/page";
function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
interface IProps extends AppProps{
Component: PageComponent
}
export default MyApp
function App({Component, pageProps}: IProps) {
const {children, ...rest} = pageProps;
// const layout = Component.layout || ((page) => page)
return (
<ThemeProvider>
<Component {...rest}>{children}</Component>
</ThemeProvider>
);
}
export default App

View File

@ -1,11 +0,0 @@
import type { NextPage } from 'next'
const Home: NextPage = () => {
return (
<div>
Hi :)
</div>
)
}
export default Home

View File

@ -0,0 +1,26 @@
import {FC} from "react";
import {TTemplateProps} from "../types/ui.types";
import {Sidebar} from "../components/Sidebar";
import ReactMarkdown from "react-markdown";
import {IMarkdown} from "../types/data.types";
interface IProps{
markdown: IMarkdown<any>;
}
export const DefaultTemplate_Markdown: FC<TTemplateProps<IProps>> = (props) => {
const {append = false, markdown} = props;
return (
<>
<Sidebar/>
<main>
{!append&&props.children}
<ReactMarkdown>
{markdown.content}
</ReactMarkdown>
{append&&props.children}
</main>
</>
)
}

21
types/data.types.ts Normal file
View File

@ -0,0 +1,21 @@
import {ParsedUrlQuery} from "querystring";
export interface IMarkdown<D>{
content: string;
metadata: D & {[key: string]: any}
}
export interface IRouteParamsMarkdown extends ParsedUrlQuery {
path: string[];
title: string;
}
export interface IPagePropsMarkdown{
markdown: IMarkdown<any>;
routeParams: IRouteParamsMarkdown
}
export interface INavigationItemProps extends ParsedUrlQuery{
path: string[];
title: string;
}

7
types/page.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import {NextPage} from "next";
import {ComponentType, ReactElement, ReactNode} from "react";
export type PageComponent<P = {}> = NextPage<P> & {
layout?: (page: ReactElement) => ReactNode
// layout?: ComponentType
}

14
types/ui.types.ts Normal file
View File

@ -0,0 +1,14 @@
import {PropsWithChildren} from "react";
import {INavigationItemProps} from "./data.types";
export type TTemplateProps<T = {}> = {
title?: string;
description?: string;
tags?: string;
append?: boolean
} & T & PropsWithChildren<T>
export interface ISidebarPropsBase{
items: INavigationItemProps[];
}

View File

@ -0,0 +1,57 @@
import type {GetStaticPathsResult, GetStaticPropsContext, GetStaticPropsResult} from "next/types";
import glob from "fast-glob";
import {sep, basename, join} from "path";
import slugify from "@sindresorhus/slugify";
import preval from 'next-plugin-preval';
import {INavigationItemProps, IPagePropsMarkdown, IRouteParamsMarkdown} from "../../types/data.types";
import {readFileSync} from "fs";
import matter from "gray-matter";
import {ISidebarPropsBase} from "../../types/ui.types";
export const markdownFileToNavLinkProps = (dirname: string, filepath: string): INavigationItemProps => ({
path: mdFilePathToSlugPath(dirname, filepath),
title: basename(filepath, ".md")
});
const mdFilePathToSlugPath = (dirname: string, p: string): string[] => {
const cleanP = p.replace(dirname, "").replace(".md", "");
return cleanP.split(sep).slice(1).map(s => slugify(s));
}
const getStaticPathsFromFolder = async(dirname: string): Promise<GetStaticPathsResult<IRouteParamsMarkdown>> => {
const files = await glob(`${dirname}/**/*.md`);
return {
paths: files.map(f => ({
params: markdownFileToNavLinkProps(dirname, f)
})),
fallback: false
}
}
export const getStaticPropsFromFolder = async (dir: string, context: GetStaticPropsContext<IRouteParamsMarkdown, IPagePropsMarkdown>): Promise<GetStaticPropsResult<IPagePropsMarkdown>> => {
const params = context.params!
const rawMD = readFileSync(join(dir,params.path.join(sep))+".md", 'utf-8');
const {data: metadata, content} = matter(rawMD);
return {
props: {
markdown: {content, metadata},
routeParams: params
},
};
}
async function getData(dirname: string): Promise<ISidebarPropsBase> {
const files = await glob(`${dirname}/**/*.md`);
return { items: files.map(f => markdownFileToNavLinkProps(dirname, f))}
}
export const markdownDataUtils = {
getStaticPaths: getStaticPathsFromFolder,
getStaticProps: getStaticPropsFromFolder,
}
export const getSidebarData = (dirname: string) => preval(getData(dirname));

2357
yarn.lock

File diff suppressed because it is too large Load Diff