mirror of
https://github.com/privateersclub/wiki.git
synced 2025-02-19 20:31:17 +00:00
fix my prettier atrocities
This commit is contained in:
parent
0cdbe1ffb8
commit
eb1c0d9b5f
14
.prettierrc
14
.prettierrc
@ -1,14 +0,0 @@
|
||||
{
|
||||
"semi": true,
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": false,
|
||||
"quoteProps": "as-needed",
|
||||
"jsxSingleQuote": false,
|
||||
"trailingComma": "all",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": true,
|
||||
"arrowParens": "always",
|
||||
"proseWrap": "always"
|
||||
}
|
@ -26,11 +26,16 @@ defineProps<{ title: string; description?: string }>();
|
||||
#286749 87.8%,
|
||||
#22543d 97%
|
||||
);
|
||||
">
|
||||
<div tw="p-10 w-full min-h-0 grow flex flex-col items-center justify-between">
|
||||
"
|
||||
>
|
||||
<div
|
||||
tw="p-10 w-full min-h-0 grow flex flex-col items-center justify-between"
|
||||
>
|
||||
<div tw="w-full flex justify-between items-center text-5xl font-medium">
|
||||
<div tw="flex items-center">
|
||||
<div tw="text-zinc-100 ml-2 mt-1 font-semibold">the privateersclub wiki</div>
|
||||
<div tw="text-zinc-100 ml-2 mt-1 font-semibold">
|
||||
the privateersclub wiki
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div tw="w-full pr-56 flex flex-col items-start justify-end">
|
||||
@ -39,7 +44,8 @@ defineProps<{ title: string; description?: string }>();
|
||||
v-if="description"
|
||||
style="color: #adf0dd; text-decoration-style: dotted"
|
||||
tw="mt-2 text-4xl underline"
|
||||
v-html="description" />
|
||||
v-html="description"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div tw="shrink-0 h-4 w-full flex" style="background-color: #adf0dd" />
|
||||
|
@ -49,22 +49,33 @@ export function generateMeta(context: TransformContext, hostname: string) {
|
||||
]);
|
||||
} else {
|
||||
const url = pageData.filePath.replace("index.md", "").replace(".md", "");
|
||||
const imageUrl = `${url}/__og_image__/og.png`.replaceAll("//", "/").replace(/^\//, "");
|
||||
const imageUrl = `${url}/__og_image__/og.png`
|
||||
.replaceAll("//", "/")
|
||||
.replace(/^\//, "");
|
||||
|
||||
head.push(
|
||||
["meta", { property: "og:image", content: `${hostname}/${imageUrl}` }],
|
||||
["meta", { property: "og:image:width", content: "1200" }],
|
||||
["meta", { property: "og:image:height", content: "628" }],
|
||||
["meta", { property: "og:image:type", content: "image/png" }],
|
||||
["meta", { property: "og:image:alt", content: pageData.frontmatter.title }],
|
||||
[
|
||||
"meta",
|
||||
{ property: "og:image:alt", content: pageData.frontmatter.title },
|
||||
],
|
||||
["meta", { name: "twitter:image", content: `${hostname}/${imageUrl}` }],
|
||||
["meta", { name: "twitter:image:width", content: "1200" }],
|
||||
["meta", { name: "twitter:image:height", content: "628" }],
|
||||
["meta", { name: "twitter:image:alt", content: pageData.frontmatter.title }],
|
||||
[
|
||||
"meta",
|
||||
{ name: "twitter:image:alt", content: pageData.frontmatter.title },
|
||||
],
|
||||
);
|
||||
}
|
||||
if (pageData.frontmatter.tag) {
|
||||
head.push(["meta", { property: "article:tag", content: pageData.frontmatter.tag }]);
|
||||
head.push([
|
||||
"meta",
|
||||
{ property: "article:tag", content: pageData.frontmatter.tag },
|
||||
]);
|
||||
}
|
||||
if (pageData.frontmatter.date) {
|
||||
head.push([
|
||||
|
@ -11,7 +11,10 @@ const __fonts = resolve(__dirname, "../fonts");
|
||||
|
||||
export async function generateImages(config: SiteConfig): Promise<void> {
|
||||
const pages = await createContentLoader("**/*.md", { excerpt: true }).load();
|
||||
const template = await readFile(resolve(__dirname, "./Template.vue"), "utf-8");
|
||||
const template = await readFile(
|
||||
resolve(__dirname, "./Template.vue"),
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
const fonts: SatoriOptions["fonts"] = [
|
||||
{
|
||||
|
@ -19,9 +19,11 @@ title: Emulação
|
||||
|
||||
# Emuladores
|
||||
|
||||
:::tip :exclamation: Veja a
|
||||
:::tip
|
||||
:exclamation: Veja a
|
||||
**[Emulation General Wiki](https://emulation.gametechwiki.com/index.php/Main_Page#Emulators)** para
|
||||
mais. :::
|
||||
mais.
|
||||
:::
|
||||
|
||||
- [RetroArch](https://retroarch.com) - Jogos de múltiplos consoles
|
||||
- [Ryujinx](https://ryujinx.org) - Jogos de Nintendo Switch
|
||||
|
@ -8,16 +8,21 @@ material de referência para revisar rapidamente.
|
||||
|
||||
## Termos
|
||||
|
||||
::: tip O que é a Cena? E P2P? A Cena é uma comunidade underground de pessoas que crackeiam e
|
||||
::: tip O que é a Cena? E P2P?
|
||||
A Cena é uma comunidade underground de pessoas que crackeiam e
|
||||
compartilham material protegido por direitos autorais. Eles têm regras estritas que todos os membros
|
||||
da cena devem seguir. Os P2P são crackers independentes que não seguem as regras da Cena.
|
||||
|
||||
As regras da Cena: https://scenerules.org :::
|
||||
As regras da Cena: https://scenerules.org
|
||||
:::
|
||||
|
||||
::: tip O que são NFOs? NFOs são como um leiame.txt que a Cena faz nos lançamentos. Ele te dá
|
||||
instruções, uma descrição geral do jogo e informações adicionais. :::
|
||||
::: tip O que são NFOs?
|
||||
NFOs são como um leiame.txt que a Cena faz nos lançamentos. Ele te dá
|
||||
instruções, uma descrição geral do jogo e informações adicionais.
|
||||
:::
|
||||
|
||||
::: tip Por que o site X tem tantos anúncios? **Use um bloqueador de anúncios**. Anúncios mantêm os
|
||||
::: tip Por que o site X tem tantos anúncios?
|
||||
**Use um bloqueador de anúncios**. Anúncios mantêm os
|
||||
sites funcionando, mas às vezes o anúncio arruina a experiência ou até mesmo pode conter malware.
|
||||
Você pode seguir estes passos se deseja uma experiência sem anúncios:
|
||||
|
||||
@ -41,16 +46,21 @@ redirecionamentos.
|
||||
### iOS
|
||||
|
||||
O [**NextDNS**](https://nextdns.io) deve cobrir tudo para bloqueio de anúncios e rastreadores em
|
||||
todo o sistema. Você também pode experimenar o [**AhaDNS**](https://ahadns.com). :::
|
||||
todo o sistema. Você também pode experimenar o [**AhaDNS**](https://ahadns.com).
|
||||
:::
|
||||
|
||||
::: tip Eu preciso de uma VPN ao baixar? The necessity of using a VPN depends on the method of
|
||||
::: tip Eu preciso de uma VPN ao baixar?
|
||||
The necessity of using a VPN depends on the method of
|
||||
downloading. For direct downloads, a VPN is typically unnecessary. However, if you're engaging in
|
||||
peer-to-peer (P2P) activities such as torrenting, it's advisable to employ a VPN for enhanced
|
||||
security and privacy. Additionally, the legal ramifications in your area play a crucial role; if the
|
||||
consequences are lenient, you might opt to forgo using a VPN altogether. :::
|
||||
consequences are lenient, you might opt to forgo using a VPN altogether.
|
||||
:::
|
||||
|
||||
::: tip Por que o meu download é tão lento? Use um gerenciador de downloads. Alguns sites impõem
|
||||
::: tip Por que o meu download é tão lento?
|
||||
Use um gerenciador de downloads. Alguns sites impõem
|
||||
limites de transferência de arquivos para um único thread, restringindo assim as velocidades de
|
||||
download. Gerenciadores de download superam essa limitação aproveitando vários threads para o
|
||||
download, resultando em velocidades de download mais rápidas. Temos algumas recomendações
|
||||
[aqui](/br/useful). :::
|
||||
[aqui](/br/useful).
|
||||
:::
|
||||
|
@ -7,8 +7,7 @@ description: Tudo sobre pirataria no Linux.
|
||||
|
||||
## Sites de downloads diretos
|
||||
|
||||
- 🌟
|
||||
[Torrminatorr](https://forum.torrminatorr.com/viewforum.php?f=26&sid=73aa6976e6987fec6b1f09717cbe6c59) -
|
||||
- 🌟 [Torrminatorr](https://forum.torrminatorr.com/viewforum.php?f=26&sid=73aa6976e6987fec6b1f09717cbe6c59) -
|
||||
Jogos de Linux
|
||||
- 🌟 [KAPITALSIN](https://kapitalsin.com/forum) - Jogos de Linux - [Tradutor](useful.md#translator)
|
||||
- 🌟 [CS.RIN.RU](https://cs.rin.ru/forum) - Arquivos da Steam
|
||||
@ -31,7 +30,9 @@ description: Tudo sobre pirataria no Linux.
|
||||
|
||||
## Ferramentas
|
||||
|
||||
::: info Todas as ferramentas são boas, destacadas com uma estrela ou não. :::
|
||||
::: info
|
||||
Todas as ferramentas são boas, destacadas com uma estrela ou não.
|
||||
:::
|
||||
|
||||
- [MangoHud](https://github.com/flightlessmango/MangoHud) - Sobreposição para monitoração de FPS,
|
||||
temperatura e mais.
|
||||
@ -45,7 +46,10 @@ description: Tudo sobre pirataria no Linux.
|
||||
- 🌟
|
||||
[Instalar repacks com o Lutris](https://www.reddit.com/r/LinuxCrackSupport/comments/yqfirv/how_to_install_fitgirl_or_dodi_windows_repacks_in)
|
||||
- [Correção para erros de DLL](https://reddit.com/r/LinuxCrackSupport/comments/tirarp/psa_when_installing_repacks_with_custom_wine)
|
||||
::: info É recomendado adquirir jogos pelo DODI em vez da FitGirl. :::
|
||||
|
||||
::: info
|
||||
É recomendado adquirir jogos pelo DODI em vez da FitGirl.
|
||||
:::
|
||||
|
||||
# Subreddits Relacionados
|
||||
|
||||
|
@ -35,7 +35,9 @@ title: Programas
|
||||
|
||||
# VPNs
|
||||
|
||||
:::danger **Tor Browser não é uma VPN, sem proteção ao torrentear!** :::
|
||||
::: danger
|
||||
**Tor Browser não é uma VPN, sem proteção ao torrentear!**
|
||||
:::
|
||||
|
||||
- [r/VPN](https://www.reddit.com/r/VPN)
|
||||
- [Recomendações de VPNs do Privacy Guides](https://www.privacyguides.org/vpn)
|
||||
|
@ -15,7 +15,8 @@ para o adicionar ao uBlock Origin (use
|
||||
[isto](https://raw.githubusercontent.com/privateersclub/wiki/master/unsafe_uBlock.txt) em
|
||||
"Importar…").
|
||||
|
||||
:::danger **GRUPOS DA CENA NÃO TÊM SITES! Sites com o nome de um grupo da Cena na URL são falsos.**
|
||||
:::danger
|
||||
**GRUPOS DA CENA NÃO TÊM SITES! Sites com o nome de um grupo da Cena na URL são falsos.**
|
||||
:::
|
||||
|
||||
- AGFY - Links de golpes.
|
||||
|
@ -58,9 +58,11 @@ faltando no seu computador.
|
||||
- [RapidCRC](https://ov2.eu/programs/rapidcrc-unicode) - Verificador de soma de verificação e
|
||||
gerador de informações de hash
|
||||
|
||||
:::tip Ative produtos da Microsoft (Office e Windows) com o
|
||||
:::tip
|
||||
Ative produtos da Microsoft (Office e Windows) com o
|
||||
**[Microsoft Activation Scripts](https://github.com/massgravel/Microsoft-Activation-Scripts).**
|
||||
Visite o **[m0nkrus](https://w14.monkrus.ws)** para produtos da Adobe. :::
|
||||
Visite o **[m0nkrus](https://w14.monkrus.ws)** para produtos da Adobe.
|
||||
:::
|
||||
|
||||
# Extensões úteis de navegador
|
||||
|
||||
|
@ -19,9 +19,11 @@ title: Emulation
|
||||
|
||||
# Emulators
|
||||
|
||||
:::tip :exclamation: See the
|
||||
:::tip
|
||||
:exclamation: See the
|
||||
**[Emulation General Wiki](https://emulation.gametechwiki.com/index.php/Main_Page#Emulators)** for
|
||||
more. :::
|
||||
more.
|
||||
:::
|
||||
|
||||
- [RetroArch](https://retroarch.com) - Multiple consoles games
|
||||
- [Ryujinx](https://ryujinx.org) - Nintendo Switch games
|
||||
|
@ -8,16 +8,21 @@ referential material to gloss over quickly.
|
||||
|
||||
## Terms
|
||||
|
||||
::: tip What is the Scene? And P2P? The Scene is an underground community of people who crack and
|
||||
::: tip What is the Scene? And P2P?
|
||||
The Scene is an underground community of people who crack and
|
||||
share copyrighted material. They have strict rules that all scene members have to abide. P2P are
|
||||
independent crackers who don't follow the Scene rules.
|
||||
|
||||
The Scene rules: https://scenerules.org :::
|
||||
The Scene rules: https://scenerules.org
|
||||
:::
|
||||
|
||||
::: tip What are NFOs? NFOs are like a readme.txt that Scene makes on release. It gives you
|
||||
instructions, a general description of the game and some additional information. :::
|
||||
::: tip What are NFOs?
|
||||
NFOs are like a readme.txt that Scene makes on release. It gives you
|
||||
instructions, a general description of the game and some additional information.
|
||||
:::
|
||||
|
||||
::: tip Why does X site have so many ads? **Use an adblocker**. Ads keep the websites running, but
|
||||
::: tip Why does X site have so many ads?
|
||||
**Use an adblocker**. Ads keep the websites running, but
|
||||
sometimes the ad ruin the experience or even link malware. You can take these steps if you want an
|
||||
ad-free experience:
|
||||
|
||||
@ -40,15 +45,20 @@ as uBlock Origin. You can also use [FastForward](https://fastforward.team) or
|
||||
### iOS
|
||||
|
||||
[**NextDNS**](https://nextdns.io) should cover everything for system-wide ads & trackers. You can
|
||||
also try [**AhaDNS**](https://ahadns.com). :::
|
||||
also try [**AhaDNS**](https://ahadns.com).
|
||||
:::
|
||||
|
||||
::: tip Do I need to use VPN while downloading? The necessity of using a VPN depends on the method
|
||||
::: tip Do I need to use VPN while downloading?
|
||||
The necessity of using a VPN depends on the method
|
||||
of downloading. For direct downloads, a VPN is typically unnecessary. However, if you're engaging in
|
||||
peer-to-peer (P2P) activities such as torrenting, it's advisable to employ a VPN for enhanced
|
||||
security and privacy. Additionally, the legal ramifications in your area play a crucial role; if the
|
||||
consequences are lenient, you might opt to forgo using a VPN altogether. :::
|
||||
consequences are lenient, you might opt to forgo using a VPN altogether.
|
||||
:::
|
||||
|
||||
::: tip Why is my download so slow? Use a download manager. Some websites impose file transfer
|
||||
::: tip Why is my download so slow?
|
||||
Use a download manager. Some websites impose file transfer
|
||||
limits for a single thread, thereby restricting download speeds. Download managers overcome this
|
||||
limitation by leveraging multiple threads for downloading, resulting in faster download speeds. We
|
||||
have listed some recommended ones [here](/useful). :::
|
||||
have listed some recommended ones [here](/useful).
|
||||
:::
|
||||
|
@ -7,8 +7,7 @@ description: Everything regarding piracy on Linux.
|
||||
|
||||
## Direct download sites
|
||||
|
||||
- 🌟
|
||||
[Torrminatorr](https://forum.torrminatorr.com/viewforum.php?f=26&sid=73aa6976e6987fec6b1f09717cbe6c59) -
|
||||
- 🌟 [Torrminatorr](https://forum.torrminatorr.com/viewforum.php?f=26&sid=73aa6976e6987fec6b1f09717cbe6c59) -
|
||||
Linux games
|
||||
- 🌟 [KAPITALSIN](https://kapitalsin.com/forum) - Linux games - [Translator](useful.md#translator)
|
||||
- 🌟 [CS.RIN.RU](https://cs.rin.ru/forum) - Steam files
|
||||
@ -31,7 +30,9 @@ description: Everything regarding piracy on Linux.
|
||||
|
||||
## Tools
|
||||
|
||||
::: info All the tools are good whether starred or not. :::
|
||||
::: info
|
||||
All the tools are good whether starred or not.
|
||||
:::
|
||||
|
||||
- [MangoHud](https://github.com/flightlessmango/MangoHud) - Overlay for monitoring FPS, temperature,
|
||||
and more.
|
||||
@ -45,7 +46,10 @@ description: Everything regarding piracy on Linux.
|
||||
- 🌟
|
||||
[Installing repacks with Lutris](https://www.reddit.com/r/LinuxCrackSupport/comments/yqfirv/how_to_install_fitgirl_or_dodi_windows_repacks_in)
|
||||
- [Fix for DLL errors](https://reddit.com/r/LinuxCrackSupport/comments/tirarp/psa_when_installing_repacks_with_custom_wine)
|
||||
::: info It's recommended to get games from DODI over FitGirl. :::
|
||||
|
||||
::: info
|
||||
It's recommended to get games from DODI over FitGirl.
|
||||
:::
|
||||
|
||||
# Related Subreddits
|
||||
|
||||
|
@ -34,7 +34,9 @@ title: Software
|
||||
|
||||
# VPNs
|
||||
|
||||
:::danger **Tor Browser isn't a VPN, no protection for torrenting!** :::
|
||||
::: danger
|
||||
**Tor Browser isn't a VPN, no protection for torrenting!**
|
||||
:::
|
||||
|
||||
- [r/VPN](https://www.reddit.com/r/VPN)
|
||||
- [Privacy Guides' VPN recommendations](https://www.privacyguides.org/vpn)
|
||||
|
@ -4,6 +4,7 @@ title: Unsafe
|
||||
|
||||
# Untrusted sites and uploaders
|
||||
|
||||
::: tip
|
||||
You can just use the FMHY Unsafe Sites/Software adblock filter on uBlacklist (more efficient) and
|
||||
uBlock Origin to block most of the sites mentioned here and more. Follow
|
||||
[this guide](https://iorate.github.io/ublacklist/docs/advanced-features#subscription) to add the
|
||||
@ -14,8 +15,11 @@ under "URL") and
|
||||
to add it to uBlock Origin (use
|
||||
[this](https://raw.githubusercontent.com/privateersclub/wiki/master/unsafe_uBlock.txt) under
|
||||
"Import…").
|
||||
:::
|
||||
|
||||
:::danger **SCENE GROUPS HAVE NO SITES! Sites with a Scene group name in the URL are fake.** :::
|
||||
:::danger
|
||||
**SCENE GROUPS HAVE NO SITES! Sites with a Scene group name in the URL are fake.**
|
||||
:::
|
||||
|
||||
- AGFY - Scam links.
|
||||
- AimHaven - Malicious redirect ads.
|
||||
|
@ -51,9 +51,11 @@ on your computer.
|
||||
- [Parsec](https://parsec.app) - Low-latency game streaming software
|
||||
- [RapidCRC](https://ov2.eu/programs/rapidcrc-unicode) - Checksum verifier and hash info generator
|
||||
|
||||
:::tip Activate Microsoft products (Office and Windows) with
|
||||
::: tip
|
||||
Activate Microsoft products (Office and Windows) with
|
||||
**[Microsoft Activation Scripts](https://github.com/massgravel/Microsoft-Activation-Scripts).**
|
||||
Visit **[m0nkrus](https://w14.monkrus.ws)** for Adobe products. :::
|
||||
Visit **[m0nkrus](https://w14.monkrus.ws)** for Adobe products.
|
||||
:::
|
||||
|
||||
# Useful browser extensions
|
||||
|
||||
|
@ -33,6 +33,13 @@
|
||||
"statusByFile.heading": "Translation status by file"
|
||||
}
|
||||
},
|
||||
"ignoreKeywords": ["lunaria-ignore", "typo", "en-only", "broken link", "i18nReady", "i18nIgnore"],
|
||||
"ignoreKeywords": [
|
||||
"lunaria-ignore",
|
||||
"typo",
|
||||
"en-only",
|
||||
"broken link",
|
||||
"i18nReady",
|
||||
"i18nIgnore"
|
||||
],
|
||||
"renderer": "./lunaria/renderer.config.ts"
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ import { html } from "@lunariajs/core";
|
||||
|
||||
export const TitleParagraph = () => html`
|
||||
<p>
|
||||
If you're interested in helping us translate into one of the languages listed below, you've come
|
||||
to the right place! This auto-updating page always lists all the content that could use your
|
||||
help right now.
|
||||
If you're interested in helping us translate into one of the languages
|
||||
listed below, you've come to the right place! This auto-updating page always
|
||||
lists all the content that could use your help right now.
|
||||
</p>
|
||||
`;
|
||||
|
@ -7,10 +7,15 @@
|
||||
--theme-text-bright: hsl(0, 0%, 100%);
|
||||
--overlay-blurple: hsla(168, 100%, 75%, 0.2);
|
||||
|
||||
--ln-color-background: linear-gradient(215deg, var(--overlay-blurple), transparent 40%),
|
||||
radial-gradient(var(--overlay-blurple), transparent 40%) no-repeat -60vw -40vh / 105vw 200vh,
|
||||
radial-gradient(var(--overlay-blurple), transparent 65%) no-repeat 50% calc(100% + 20rem) /
|
||||
60rem 30rem,
|
||||
--ln-color-background: linear-gradient(
|
||||
215deg,
|
||||
var(--overlay-blurple),
|
||||
transparent 40%
|
||||
),
|
||||
radial-gradient(var(--overlay-blurple), transparent 40%) no-repeat -60vw -40vh /
|
||||
105vw 200vh,
|
||||
radial-gradient(var(--overlay-blurple), transparent 65%) no-repeat 50%
|
||||
calc(100% + 20rem) / 60rem 30rem,
|
||||
var(--theme-bg);
|
||||
--ln-color-link: var(--theme-accent);
|
||||
--ln-color-black: var(--theme-text);
|
||||
|
12
package.json
12
package.json
@ -4,7 +4,7 @@
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"format": "prettier --log-level=warn --write .",
|
||||
"format": "prettier --log-level=warn --write docs/",
|
||||
"build": "pnpm run docs:build && pnpm run i18n:build",
|
||||
"docs:dev": "vitepress dev docs",
|
||||
"docs:build": "vitepress build docs",
|
||||
@ -16,17 +16,17 @@
|
||||
},
|
||||
"license": "Unlicense",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.13.0",
|
||||
"@types/node": "^20.14.2",
|
||||
"@types/nprogress": "^0.2.3",
|
||||
"prettier": "^3.3.0",
|
||||
"prettier": "^3.3.1",
|
||||
"vitepress": "npm:@taskylizard/vitepress@1.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lunariajs/core": "^0.1.0",
|
||||
"@resvg/resvg-js": "^2.6.0",
|
||||
"@resvg/resvg-js": "^2.6.2",
|
||||
"nprogress": "^0.2.0",
|
||||
"unocss": "^0.58.5",
|
||||
"vue": "^3.4.18",
|
||||
"unocss": "^0.60.4",
|
||||
"vue": "^3.4.27",
|
||||
"x-satori": "^0.1.5"
|
||||
}
|
||||
}
|
||||
|
802
pnpm-lock.yaml
generated
802
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
76
shared.ts
76
shared.ts
@ -1,76 +0,0 @@
|
||||
// @ts-nocheck
|
||||
|
||||
import { toc } from "mdast-util-toc";
|
||||
import { remark } from "remark";
|
||||
import { visit } from "unist-util-visit";
|
||||
|
||||
const textTypes = ["text", "emphasis", "strong", "inlineCode"];
|
||||
|
||||
function flattenNode(node) {
|
||||
const p = [];
|
||||
visit(node, (node) => {
|
||||
if (!textTypes.includes(node.type)) return;
|
||||
p.push(node.value);
|
||||
});
|
||||
return p.join(``);
|
||||
}
|
||||
|
||||
interface Item {
|
||||
title: string;
|
||||
url: string;
|
||||
items?: Item[];
|
||||
}
|
||||
|
||||
export interface Items {
|
||||
items?: Item[];
|
||||
}
|
||||
|
||||
function getItems(node, current): Items {
|
||||
if (!node) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (node.type === "paragraph") {
|
||||
visit(node, (item) => {
|
||||
if (item.type === "link") {
|
||||
current.url = item.url;
|
||||
current.title = flattenNode(node);
|
||||
}
|
||||
|
||||
if (item.type === "text") {
|
||||
current.title = flattenNode(node);
|
||||
}
|
||||
});
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
if (node.type === "list") {
|
||||
current.items = node.children.map((i) => getItems(i, {}));
|
||||
|
||||
return current;
|
||||
} else if (node.type === "listItem") {
|
||||
const heading = getItems(node.children[0], {});
|
||||
|
||||
if (node.children.length > 1) {
|
||||
getItems(node.children[1], heading);
|
||||
}
|
||||
|
||||
return heading;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
const getToc = () => (node, file) => {
|
||||
const table = toc(node);
|
||||
file.data = getItems(table.map, {});
|
||||
};
|
||||
|
||||
export type TableOfContents = Items;
|
||||
|
||||
export async function getTableOfContents(content: string): Promise<TableOfContents> {
|
||||
const result = await remark().use(getToc).process(content);
|
||||
|
||||
return result.data;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user