add grouping to markdown stuff

This commit is contained in:
Cloudburst 2022-08-28 11:59:41 +02:00
parent 96bd6eed57
commit 400285e8a2
17 changed files with 120 additions and 32 deletions

View file

@ -2,9 +2,9 @@ import React from "react";
import { Link } from "gatsby"; import { Link } from "gatsby";
import { node2slug } from "../../utils"; import { node2slug } from "../../utils";
const DocsCard = ({ md }) => { const DocsCard = ({ md, width }) => {
return <article className="card card bg-base-200 shadow-xl w-full mx-10 md:w-2/3 mb-5"> return <article className={"card card bg-base-200 shadow-xl mx-10 mb-5 " + (width || "w-full md:w-2/3")}>
<div className="card-body"> <div className="card-body">
<h2 className="card-title">{md.frontmatter.title}</h2> <h2 className="card-title">{md.frontmatter.title}</h2>
<p> <p>

View file

@ -4,20 +4,46 @@ import React from "react"
import { Link } from "gatsby" import { Link } from "gatsby"
import { node2slug } from "../utils" import { node2slug } from "../utils"
function ChildrenNodes({nodes, parent}) {
const filtered = nodes.filter(it => {
return it.frontmatter.parent === parent
})
if (filtered.length < 1) return <></>
if (parent === null) {
return <>{filtered.map(it => {
return <li>
<Link to={node2slug(it)}>{it.frontmatter.title}</Link>
<ChildrenNodes nodes={nodes} parent={it.frontmatter.title} />
</li>
})}</>
}
return <a><details>{filtered.map(it => {
return <li>
<Link to={node2slug(it)}>{it.frontmatter.title}</Link>
<ChildrenNodes nodes={nodes} parent={it.frontmatter.title} />
</li>
})}</details></a>
}
const Drawer = () => ( const Drawer = () => (
<ul className="menu p-4 overflow-y-auto w-80 bg-base-100 text-base-content"> <ul className="menu p-4 overflow-y-auto w-80 bg-base-100 text-base-content">
<li><Link to="/">Home</Link></li> <li><Link to="/">Home</Link></li>
<li><Link to="/repos">Repositories</Link></li> <li><Link to="/repos">Repositories</Link></li>
<div className="divider">Docs</div> <div className="divider">Docs</div>
<li><Link to="/docs">Documentation</Link></li>
<li><a href="/dokka/">Dokka</a></li> <li><a href="/dokka/">Dokka</a></li>
<li><Link to="/docs">Documentation</Link></li>
<StaticQuery <StaticQuery
query={graphql` query={graphql`
query { query {
allMarkdownRemark { allMarkdownRemark(sort: {fields: frontmatter___order}) {
nodes { nodes {
frontmatter { frontmatter {
title title
order
parent
} }
fileAbsolutePath fileAbsolutePath
} }
@ -25,9 +51,7 @@ const Drawer = () => (
} }
`} `}
render={data => ( render={data => (
<>{data.allMarkdownRemark.nodes.map(it => { <ChildrenNodes nodes={Array.from(data.allMarkdownRemark.nodes)} parent={null} />
return <li><Link to={node2slug(it)}>{it.frontmatter.title}</Link></li>
})}</>
)} )}
/> />
</ul>) </ul>)

View file

@ -6,19 +6,31 @@ import Drawer from "./drawer"
import './layout.css' import './layout.css'
const Layout = ({ children }) => ( const Layout = ({ children }) => (
<div className="drawer bg-base"> <div className="drawer bg-base min-h-screen">
<input id="drawer" type="checkbox" className="drawer-toggle" /> <input id="drawer" type="checkbox" className="drawer-toggle" />
<div className="drawer-content items-center flex flex-none flex-col"> <div className="drawer-content items-center flex flex-none flex-col min-h-screen">
<Navbar /> <Navbar />
<div className="pb-10 w-full text-base-content"> <div className="pb-10 w-full text-base-content grow">
{children} {children}
</div> </div>
<footer class="footer footer-center p-10 mt-15 bg-base-200 text-base-content rounded gap-2">
<div class="grid grid-flow-col gap-4">
<a class="link link-hover" href="https://discord.gg/5Hus6fM">Contact</a>
<a class="link link-hover" href="https://github.com/recloudstream/">Github</a>
<a class="link link-hover" href="https://discord.gg/5Hus6fM">Discord</a>
<a class="link link-hover" href="https://matrix.to/#/#lagrapps:matrix.org">Matrix</a>
<a class="link link-hover" onClick={() => {window.open("https://www.youtube.com/watch?v=f-UIBVsRSDQ")}}>DMCA</a>
</div>
<div>
<p>Website by <a className="link" href="https://wilkins.ml" target="_blank">Cloudburst</a></p>
</div>
</footer>
</div> </div>
<div className="drawer-side"> <div className="drawer-side">
<label for="drawer" className="drawer-overlay backdrop-blur-sm"></label> <label for="drawer" className="drawer-overlay backdrop-blur-sm"></label>
<Drawer /> <Drawer />
</div> </div>
</div> </div>
) )
export default Layout export default Layout

View file

@ -1,5 +1,7 @@
--- ---
title: Creating your own JSON repository title: Creating your own JSON repository
parent: For extension developers
order: 4
--- ---
# Creating your own JSON repository # Creating your own JSON repository

View file

@ -1,5 +1,7 @@
--- ---
title: Creating your own providers title: Creating your own providers
parent: For extension developers
order: 2
--- ---
# Creating your own Providers # Creating your own Providers

View file

@ -1,5 +1,7 @@
--- ---
title: For extension developers title: For extension developers
parent: null
order: 2
--- ---
# For extension developers # For extension developers

View file

@ -1,5 +1,7 @@
--- ---
title: Devtools detector title: Devtools detector
parent: Scraping tutorial
order: 3
--- ---
**TL;DR**: You are going to get fucked by sites detecting your devtools, the easiest bypass for this is using [a web sniffer extension](https://chrome.google.com/webstore/detail/web-sniffer/ndfgffclcpdbgghfgkmooklaendohaef?hl=en) **TL;DR**: You are going to get fucked by sites detecting your devtools, the easiest bypass for this is using [a web sniffer extension](https://chrome.google.com/webstore/detail/web-sniffer/ndfgffclcpdbgghfgkmooklaendohaef?hl=en)

View file

@ -1,5 +1,7 @@
--- ---
title: Disguishing your scrapers title: Disguishing your scrapers
parent: Scraping tutorial
order: 4
--- ---
# Disguishing your scrapers # Disguishing your scrapers

View file

@ -1,5 +1,7 @@
--- ---
title: Finding video links title: Finding video links
parent: Scraping tutorial
order: 5
--- ---
# Finding video links # Finding video links

View file

@ -1,5 +1,7 @@
--- ---
title: Scraping tutorial title: Scraping tutorial
parent: For extension developers
order: 3
--- ---
# Requests based scraping tutorial # Requests based scraping tutorial

View file

@ -1,5 +1,7 @@
--- ---
title: Starting title: Starting
parent: Scraping tutorial
order: 1
--- ---
Scraping is just downloading a webpage and getting the wanted information from it. Scraping is just downloading a webpage and getting the wanted information from it.

View file

@ -1,5 +1,7 @@
--- ---
title: Using APIs title: Using APIs
parent: Scraping tutorial
order: 2
--- ---
### About ### About

View file

@ -1,5 +1,7 @@
--- ---
title: Using plugin template title: Using plugin template
parent: For extension developers
order: 1
--- ---
# Using the template # Using the template

View file

@ -11,7 +11,10 @@ const DocsPage = () => {
<StaticQuery <StaticQuery
query={graphql` query={graphql`
query { query {
allMarkdownRemark { allMarkdownRemark(
sort: {fields: frontmatter___order}
filter: {frontmatter: {parent: {eq: null}}}
) {
nodes { nodes {
id id
frontmatter { frontmatter {
@ -40,8 +43,8 @@ export default DocsPage
export function Head() { export function Head() {
return ( return (
<> <>
<title>Cloudstream 404</title> <title>Cloudstream Docs</title>
<meta property="og:title" content="Cloudstream" /> <meta property="og:title" content="Cloudstream Docs" />
<meta property="og:description" content="Cloudstream is an Android app for streaming and downloading Movies, TV-Series and Anime." /> <meta property="og:description" content="Cloudstream is an Android app for streaming and downloading Movies, TV-Series and Anime." />
<meta property="og:image" content={bgImage} /> <meta property="og:image" content={bgImage} />
<meta property="og:image:type" content="image/png" /> <meta property="og:image:type" content="image/png" />

View file

@ -1,5 +1,7 @@
--- ---
title: For users title: For users
parent: null
order: 1
--- ---
# Cloudstream # Cloudstream

View file

@ -1,5 +1,7 @@
--- ---
title: Using local extensions title: Using local extensions
parent: For users
order: 1
--- ---
It is possible to use extensions without using repositories. This can be useful when prototyping. It is possible to use extensions without using repositories. This can be useful when prototyping.

View file

@ -2,6 +2,7 @@ import React from "react"
import { Link, graphql } from "gatsby" import { Link, graphql } from "gatsby"
import Layout from "../components/layout" import Layout from "../components/layout"
import bgImage from "../media/phones.png" import bgImage from "../media/phones.png"
import DocsCard from "../components/cards/docs"
import rehypeReact from "rehype-react" import rehypeReact from "rehype-react"
@ -39,7 +40,7 @@ const componentMap = {
} }
export default function PageTemplate({ data: { markdownRemark } }) { export default function PageTemplate({ data: { markdownRemark, allMarkdownRemark } }) {
const renderAst = new rehypeReact({ const renderAst = new rehypeReact({
createElement: React.createElement, createElement: React.createElement,
components: componentMap, components: componentMap,
@ -48,6 +49,10 @@ export default function PageTemplate({ data: { markdownRemark } }) {
} }
}).Compiler }).Compiler
const filtered = allMarkdownRemark.nodes.filter(it => it.frontmatter.parent === markdownRemark.frontmatter.title).map(it => {
return <DocsCard md={it} key={it} width="w-full" />
})
return ( return (
<Layout> <Layout>
<div className="flex items-center w-full flex-col"> <div className="flex items-center w-full flex-col">
@ -60,16 +65,22 @@ export default function PageTemplate({ data: { markdownRemark } }) {
</div> </div>
<div className="w-full mx-10 md:w-2/3 card bg-base-200 shadow-xl"> <div className="w-full mx-10 md:w-2/3 card bg-base-200 shadow-xl">
<div className="card-body"> <div className="card-body">
<h2 class="card-title">{markdownRemark.frontmatter.title}</h2> <h1 class="card-title text-xl">{markdownRemark.frontmatter.title}</h1>
{renderAst(markdownRemark.htmlAst)} {renderAst(markdownRemark.htmlAst)}
</div> </div>
</div> </div>
{filtered.length > 0 && <>
<div class="divider text-xl mt-5">Children</div>
<div className="grid gap-5 w-full px-10 place-items-center auto-rows-max grid-flow-row-dense grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
{filtered}
</div></>}
</div> </div>
</Layout> </Layout>
) )
} }
export function Head({data}) { export function Head({ data }) {
return ( return (
<> <>
<title>{data.markdownRemark.frontmatter.title}</title> <title>{data.markdownRemark.frontmatter.title}</title>
@ -92,5 +103,19 @@ export const pageQuery = graphql`
excerpt excerpt
htmlAst htmlAst
} }
allMarkdownRemark(
sort: {fields: frontmatter___order}
filter: {frontmatter: {parent: {ne: null}}}
) {
nodes {
frontmatter {
title
order
parent
}
fileAbsolutePath
excerpt
}
}
} }
` `