Skip to content

Commit

Permalink
Merge remote-tracking branch 'template/main' into upgrade_blog
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelgoth committed Aug 27, 2023
2 parents 5e7e034 + 6748aa4 commit 9e15592
Show file tree
Hide file tree
Showing 14 changed files with 1,298 additions and 1,104 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<br />

<p align="center">
<a href="https://fff.js.org"><img src="https://img.shields.io/badge/%F0%9F%8C%9F%20F%20F%20F-0.5-yellow?style=flat" alt="fff" /></a>
<a href="https://fff.js.org"><img src="https://img.shields.io/badge/%F0%9F%8C%9F%20F%20F%20F-1.0-yellow?style=flat" alt="fff" /></a>
<img src="https://img.shields.io/github/languages/top/importantimport/urara?color=%23ff3e00" alt="Language" />
<a href="https://github.com/importantimport/urara/blob/main/COPYING"><img src="https://img.shields.io/github/license/importantimport/urara?color=%23fff" alt="License" /></a>
<img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fimportantimport%2Furara.svg?type=shield" alt="FOSSA Status" />
Expand Down Expand Up @@ -96,7 +96,6 @@ tyvm! ur ⭐ will give me more motivation to improve this project.

- [./kwaa.dev](https://kwaa.dev) - [kwaa/blog](https://github.com/kwaa/blog)
- [Seviche.cc](https://seviche.cc) - [Sevichecc/Urara-Blog](https://github.com/Sevichecc/Urara-Blog)
- [Antonio Sarcevic](https://www.sarcevic.dev) - [SarcevicAntonio/SarcevicAntonio](https://github.com/SarcevicAntonio/SarcevicAntonio)

and more...

Expand Down
3 changes: 1 addition & 2 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<br />

<p align="center">
<a href="https://fff.js.org"><img src="https://img.shields.io/badge/%F0%9F%8C%9F%20F%20F%20F-0.5-yellow?style=flat" alt="fff" /></a>
<a href="https://fff.js.org"><img src="https://img.shields.io/badge/%F0%9F%8C%9F%20F%20F%20F-1.0-yellow?style=flat" alt="fff" /></a>
<img src="https://img.shields.io/github/languages/top/importantimport/urara?color=%23ff3e00" alt="Language" />
<a href="https://github.com/importantimport/urara/blob/main/COPYING"><img src="https://img.shields.io/github/license/importantimport/urara?color=%23fff" alt="License" /></a>
<img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fimportantimport%2Furara.svg?type=shield" alt="FOSSA Status" />
Expand Down Expand Up @@ -96,7 +96,6 @@ pnpm build

- [./kwaa.dev](https://kwaa.dev) - [kwaa/blog](https://github.com/kwaa/blog)
- [Seviche.cc](https://seviche.cc) - [Sevichecc/Urara-Blog](https://github.com/Sevichecc/Urara-Blog)
- [Antonio Sarcevic](https://www.sarcevic.dev) - [SarcevicAntonio/SarcevicAntonio](https://github.com/SarcevicAntonio/SarcevicAntonio)

和更多...

Expand Down
58 changes: 33 additions & 25 deletions mdsvex.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

// mdsvex config type
import type { MdsvexOptions } from 'mdsvex'

Expand All @@ -8,8 +10,7 @@ import rehypeExternalLinks from 'rehype-external-links'

// urara remark plugins
import type { Node, Data } from 'unist'
import { statSync } from 'fs'
import { parse, join } from 'path'
import { parse, join } from 'node:path'
import { visit } from 'unist-util-visit'
import { toString } from 'mdast-util-to-string'
import Slugger from 'github-slugger'
Expand All @@ -20,31 +21,30 @@ import remarkFootnotes from 'remark-footnotes'
import { escapeSvelte } from 'mdsvex'
import { lex, parse as parseFence } from 'fenceparser'
import { renderCodeToHTML, runTwoSlash, createShikiHighlighter } from 'shiki-twoslash'
type VALUE = { [key in string | number]: VALUE } | Array<VALUE> | string | boolean | number

const remarkUraraFm =
() =>
(tree: Node<Data>, { data, filename }: { data: { fm?: Record<string, unknown> }; filename?: string }) => {
const filepath = filename ? filename.split('/src/routes')[1] : 'unknown'
const { dir, name } = parse(filepath)
if (!data.fm) data.fm = {}
// Generate slug & path
data.fm.slug = filepath
data.fm.path = join(dir, `/${name}`.replace('/+page', '').replace('.svelte', ''))
// Generate ToC
if (data.fm.toc !== false) {
const [slugs, toc]: [slugs: Slugger, toc: { depth: number; title: string; slug: string }[]] = [new Slugger(), []]
visit(tree, 'heading', (node: { depth: number }) => {
toc.push({
depth: node.depth,
title: toString(node),
slug: slugs.slug(toString(node), false)
(tree: Node<Data>, { data, filename }: { data: { fm?: Record<string, unknown> }; filename?: string }) => {
const filepath = filename ? filename.split('/src/routes')[1] : 'unknown'
const { dir, name } = parse(filepath)
if (!data.fm) data.fm = {}
// Generate slug & path
data.fm.slug = filepath
data.fm.path = join(dir, `/${name}`.replace('/+page', '').replace('.svelte', ''))
// Generate ToC
if (data.fm.toc !== false) {
const [slugs, toc]: [slugs: Slugger, toc: { depth: number; title: string; slug: string }[]] = [new Slugger(), []]
visit(tree, 'heading', (node: { depth: number }) => {
toc.push({
depth: node.depth,
title: toString(node),
slug: slugs.slug(toString(node), false)
})
})
})
if (toc.length > 0) data.fm.toc = toc
else data.fm.toc = false
if (toc.length > 0) data.fm.toc = toc
else data.fm.toc = false
}
}
}

// Better type definitions needed
const remarkUraraSpoiler = () => (tree: Node<Data>) =>
Expand All @@ -69,7 +69,7 @@ export default {
},
highlight: {
highlighter: async (code, lang, meta) => {
let fence: Record<string, VALUE> | null
let fence: any
let twoslash: any
try {
fence = parseFence(lex([lang, meta].filter(Boolean).join(' ')))
Expand All @@ -91,13 +91,19 @@ export default {
},
remarkPlugins: [
[
remarkFFF as any,
remarkFFF,
{
presets: ['hugo'],
presets: [],
target: 'mdsvex',
autofill: {
provider: 'fs',
path: (path: string) => path.replace('/src/routes/', '/urara/')
},
strict: {
media: {
type: 'string',
array: false,
}
}
}
],
Expand All @@ -117,3 +123,5 @@ export default {
]
]
} as MdsvexOptions

/* eslint-enable @typescript-eslint/no-explicit-any */
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@
"@sveltejs/adapter-netlify": "^2.0.7",
"@sveltejs/adapter-static": "^2.0.2",
"@sveltejs/adapter-vercel": "^2.4.3",
"@sveltejs/kit": "^1.15.9",
"@sveltejs/kit": "^1.19.0",
"@tailwindcss/typography": "^0.5.9",
"@types/node": "^18.16.3",
"@types/node": "^20.2.5",
"@types/unist": "^2.0.6",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"@unocss/extractor-svelte": "^0.51.12",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"@unocss/extractor-svelte": "^0.52.4",
"@vite-pwa/sveltekit": "^0.1.3",
"chalk": "^5.2.0",
"chokidar": "^3.5.3",
"cross-env": "^7.0.3",
"daisyui": "^2.51.6",
"eslint": "^8.39.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-svelte3": "^4.0.0",
"fenceparser": "^2.2.0",
"fff-flavored-frontmatter": "~0.5.3",
"fff-flavored-frontmatter": "1.0.0-alpha.1",
"github-slugger": "^2.0.0",
"mdast-util-to-string": "^3.2.0",
"mdsvex": "^0.10.6",
Expand All @@ -56,26 +56,26 @@
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-external-links": "^2.0.1",
"rehype-external-links": "^2.1.0",
"rehype-slug": "^5.1.0",
"remark": "^14.0.2",
"remark-fff": "~0.5.3",
"remark": "^14.0.3",
"remark-fff": "1.0.0-alpha.1",
"remark-footnotes": "~2.0.0",
"shiki-twoslash": "^3.1.2",
"svelte": "^3.58.0",
"svelte-check": "^3.2.0",
"svelte-preprocess": "^5.0.3",
"svelte": "^3.59.1",
"svelte-check": "^3.4.3",
"svelte-preprocess": "^5.0.4",
"sveltekit-embed": "^0.0.13",
"tailwindcss": "^3.3.2",
"tslib": "^2.5.0",
"tslib": "^2.5.2",
"typescript": "^4.9.5",
"unist-util-visit": "^4.1.2",
"unocss": "^0.51.8",
"vite": "^4.3.3",
"unocss": "^0.52.4",
"vite": "^4.3.9",
"vite-imagetools": "^4.0.19",
"vite-plugin-pwa": "^0.14.7",
"workbox-build": "^6.5.4",
"workbox-window": "^6.5.4"
"workbox-build": "^6.6.0",
"workbox-window": "^6.6.0"
},
"pnpm": {
"overrides": {
Expand Down
Loading

1 comment on commit 9e15592

@vercel
Copy link

@vercel vercel bot commented on 9e15592 Aug 27, 2023

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.