Skip to content

Commit

Permalink
✏️ fix typo & prettify code
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Dec 26, 2021
1 parent fd816b7 commit 68b0275
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 33 deletions.
47 changes: 25 additions & 22 deletions mdsvex.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,34 @@ import { visit } from 'unist-util-visit'
import { toString } from 'mdast-util-to-string'
import { parse, join } from 'path'

const highlighter = async (code, lang) => `{@html \`${await shiki.getHighlighter({ theme: 'material-default' }).then(highlighter =>
highlighter
.codeToHtml(code, { lang })
.replace(/[{}`]/g, c => ({ '{': '{', '}': '}', '`': '`' }[c]))
.replace(/\\([trn])/g, '\$1')
)}\` }`
const highlighter = async (code, lang) =>
`{@html \`${await shiki.getHighlighter({ theme: 'material-default' }).then(highlighter =>
highlighter
.codeToHtml(code, { lang })
.replace(/[{}`]/g, c => ({ '{': '{', '}': '}', '`': '`' }[c]))
.replace(/\\([trn])/g, '\$1')
)}\` }`

const remarkUraraFm = () => (tree, { data, filename }) => {
const filepath = filename.split('/src/routes')[1]
let { dir, name } = parse(filepath)
if (!data.fm) data.fm = {}
data.fm.slug = filepath
data.fm.path = join(dir, `/${name}`.replace('\/index', '').replace('\.svelte', ''))
if (data.fm?.toc !== false) {
let [slugs, toc] = [new Slugger(), []]
visit(tree, 'heading', node => {
toc.push({
depth: node.depth,
title: toString(node),
slug: slugs.slug(toString(node))
const remarkUraraFm =
() =>
(tree, { data, filename }) => {
const filepath = filename.split('/src/routes')[1]
let { dir, name } = parse(filepath)
if (!data.fm) data.fm = {}
data.fm.slug = filepath
data.fm.path = join(dir, `/${name}`.replace('/index', '').replace('.svelte', ''))
if (data.fm?.toc !== false) {
let [slugs, toc] = [new Slugger(), []]
visit(tree, 'heading', node => {
toc.push({
depth: node.depth,
title: toString(node),
slug: slugs.slug(toString(node))
})
})
})
data.fm.toc = toc
data.fm.toc = toc
}
}
}

const remarkUraraSpoiler = () => tree =>
visit(tree, 'paragraph', node => {
Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
export { className as class }
</script>

<footer id="footer" class="{className ?? ''} footer footer-center bg-base-300 text-base-content rounded-box <md:rounded-none shadow-inner p-8">
<footer
id="footer"
class="{className ?? ''} footer footer-center bg-base-300 text-base-content rounded-box <md:rounded-none shadow-inner p-8">
<div class="prose">
<p>
{#each Object.entries(footerConfig.nav) as [href, name], i}
Expand All @@ -24,7 +26,7 @@
Powered by
<a rel="noopener external" target="_blank" href="https://github.com/sveltejs/kit">SvelteKit</a>
/
<a rel="noopener external" target="_blank" href="https://github.com/pngwn/mdsvex">MDSveX</a>
<a rel="noopener external" target="_blank" href="https://github.com/pngwn/mdsvex">MDsveX</a>
/
<a rel="noopener external" target="_blank" class="urara-link" href="https://github.com/importantimport/urara">Urara</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/config/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const dateConfig = (type: string): { locales: string; options: Intl.DateT
}
if (type === 'layout') options.year = 'numeric'
return { locales, options }
}
}
14 changes: 7 additions & 7 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const config = {
// for more information about preprocessors
preprocess: [mdsvex(mdsvexConfig), preprocess()],
kit: {
adapter: Object.keys(process.env).some(key => ['VERCEL', 'CF_PAGES', 'NETLIFY'].includes(key) )
? adapterAuto()
: adapterStatic({
pages: 'build',
assets: 'build',
fallback: null
}),
adapter: Object.keys(process.env).some(key => ['VERCEL', 'CF_PAGES', 'NETLIFY'].includes(key))
? adapterAuto()
: adapterStatic({
pages: 'build',
assets: 'build',
fallback: null
}),
target: 'body',
vite: {
mode: process.env.MODE || 'production',
Expand Down
2 changes: 1 addition & 1 deletion urara/hello-world/toc-disabled/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ When the `toc: false` on Front-Matter, toc should not be displayed.

### Heading

#### Heading
#### Heading

0 comments on commit 68b0275

Please sign in to comment.