Skip to content

Commit

Permalink
feat: slot attributes syntax (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored Nov 27, 2024
1 parent e96baaa commit 3cd5c5a
Show file tree
Hide file tree
Showing 48 changed files with 5,892 additions and 3,794 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ Temporary Items
.vercel_build_output
.build-*
.env
.netlify
.netlify
.data
6 changes: 3 additions & 3 deletions docs/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
extends: '@nuxt/eslint-config',
rules: {
'vue/max-attributes-per-line': 'off',
'vue/multi-word-component-names': 'off'
}
}
'vue/multi-word-component-names': 'off',
},
}
18 changes: 9 additions & 9 deletions docs/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ export default defineAppConfig({
nuxt: {
label: 'Nuxt',
icon: 'simple-icons:nuxtdotjs',
href: 'https://nuxt.com'
}
href: 'https://nuxt.com',
},
},

github: {
dir: 'docs/content',
branch: 'main',
repo: 'remark-mdc',
owner: 'nuxtlabs',
edit: true
edit: true,
},

aside: {
level: 0,
collapsed: false,
exclude: []
exclude: [],
},

main: {
padded: true,
fluid: false
fluid: false,
},

header: {
logo: false,
showLinkIcon: true,
exclude: [],
fluid: false,
title: 'Remark MDC'
}
}
})
title: 'Remark MDC',
},
},
})
4 changes: 2 additions & 2 deletions docs/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineNuxtConfig({
// https://github.com/nuxt-modules/plausible
'@nuxtjs/plausible',
// https://github.com/nuxt/devtools
'@nuxt/devtools'
]
'@nuxt/devtools',
],
})
27 changes: 27 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// @ts-check
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'

// Run `npx @eslint/config-inspector` to inspect the resolved config interactively
export default createConfigForNuxt({
features: {
// Rules for module authors
tooling: true,
// Rules for formatting
stylistic: true,
},
dirs: {
src: [
'./playground',
'./examples/blog',
],
},
})
.append(
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'vue/multi-word-component-names': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
},
},
)
46 changes: 24 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,46 @@
"dev": "nuxi dev playground",
"dev:prepare": "nuxi prepare playground",
"generate": "nuxi generate playground",
"lint": "eslint --ext .js,.ts,.vue .",
"lint": "eslint",
"test:ui": "pnpm lint && vitest --ui --open=false",
"test": "vitest run",
"prepack": "pnpm build",
"release": "release-it"
},
"dependencies": {
"@types/mdast": "^4.0.3",
"@types/unist": "^3.0.2",
"@types/mdast": "^4.0.4",
"@types/unist": "^3.0.3",
"flat": "^6.0.1",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-markdown": "^2.1.0",
"micromark": "^4.0.0",
"micromark-core-commonmark": "^2.0.0",
"micromark-factory-space": "^2.0.0",
"micromark-factory-whitespace": "^2.0.0",
"micromark-util-character": "^2.1.0",
"micromark-util-types": "^2.0.0",
"mdast-util-from-markdown": "^2.0.2",
"mdast-util-to-markdown": "^2.1.2",
"micromark": "^4.0.1",
"micromark-core-commonmark": "^2.0.2",
"micromark-factory-space": "^2.0.1",
"micromark-factory-whitespace": "^2.0.1",
"micromark-util-character": "^2.1.1",
"micromark-util-types": "^2.0.1",
"parse-entities": "^4.0.1",
"scule": "^1.3.0",
"stringify-entities": "^4.0.3",
"unified": "^11.0.4",
"stringify-entities": "^4.0.4",
"unified": "^11.0.5",
"unist-util-visit": "^5.0.0",
"unist-util-visit-parents": "^6.0.1",
"yaml": "^2.4.2"
"yaml": "^2.6.1"
},
"devDependencies": {
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/kit": "^3.11.1",
"@nuxt/eslint-config": "^0.7.2",
"@nuxt/kit": "^3.14.1592",
"@nuxt/ui": "3.0.0-alpha.9",
"@nuxthub/core": "^0.8.7",
"@nuxtjs/eslint-config-typescript": "latest",
"@types/flat": "^5.0.5",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.11.30",
"eslint": "^8.57.0",
"@types/node": "^22.10.0",
"eslint": "^9.15.0",
"eslint-plugin-nuxt": "latest",
"jiti": "^1.21.0",
"nuxt": "^3.11.1",
"release-it": "^17.1.1",
"jiti": "^2.4.0",
"nuxt": "^3.14.1592",
"release-it": "^17.10.0",
"remark-gfm": "^4.0.0",
"remark-parse": "^11.0.0",
"remark-stringify": "^11.0.0",
Expand All @@ -76,5 +78,5 @@
"after:bump": "npx changelogen@latest --no-commit --no-tag --output --r $(node -p \"require('./package.json').version\")"
}
},
"packageManager": "pnpm@9.12.3"
"packageManager": "pnpm@9.14.2"
}
2 changes: 2 additions & 0 deletions playground/assets/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "tailwindcss";
@import "@nuxt/ui";
6 changes: 3 additions & 3 deletions playground/composables/useMarkdownGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import type { Ref } from 'vue'
// workaround for kleur
process.env = process.env || {}

function jsonParser (this: any) {
function jsonParser(this: any) {
this.Parser = function (root: any) {
return JSON.parse(root)
}
}
export function useMarkdownGenerator (input: Ref<object>, mdcOptions = ref({})) {
export function useMarkdownGenerator(input: Ref<object>, mdcOptions = ref({})) {
let _stream: Processor<undefined, Node, Node, Root, string> | null = null
const markdown = ref('')
const generate = async (ast: object) => {
Expand All @@ -25,7 +25,7 @@ export function useMarkdownGenerator (input: Ref<object>, mdcOptions = ref({}))
.use(gfm)
.use(mdc, mdcOptions.value)
.use(stringify, {
bullet: '-'
bullet: '-',
})
}
const res = await _stream.process(JSON.stringify(ast)).then(file => file.value as string)
Expand Down
4 changes: 2 additions & 2 deletions playground/composables/useMarkdownParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import type { Ref } from 'vue'
// workaround for kleur
process.env = process.env || {}

function compiler (this: any) {
function compiler(this: any) {
this.Compiler = function (root: any) {
return root
}
}

export function useMarkdownParser (input: Ref<string>, mdcOptions = ref({})) {
export function useMarkdownParser(input: Ref<string>, mdcOptions = ref({})) {
let _stream: Processor<Root, Node, Node, undefined, undefined> | null = null
const ast = ref()
const parse = async (str: string) => {
Expand Down
8 changes: 7 additions & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { defineNuxtConfig } from 'nuxt/config'

export default defineNuxtConfig({})
export default defineNuxtConfig({
modules: [
'@nuxt/ui',
'@nuxthub/core',
],
css: ['~/assets/css/main.css'],
})
17 changes: 14 additions & 3 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<template>
<div>
<label for="autoUnwrap">
<input id="autoUnwrap" v-model="mdcOptions.experimental.autoUnwrap" type="checkbox"> auto unwrap
<input
id="autoUnwrap"
v-model="mdcOptions.experimental.autoUnwrap"
type="checkbox"
> auto unwrap
</label>
<label for="componentCodeBlockYamlProps">
<input id="componentCodeBlockYamlProps" v-model="mdcOptions.experimental.componentCodeBlockYamlProps" type="checkbox">
<input
id="componentCodeBlockYamlProps"
v-model="mdcOptions.experimental.componentCodeBlockYamlProps"
type="checkbox"
>
Component props code block style
</label>
<div class="flex">
<textarea v-model="markdown" class="flex-1" />
<textarea
v-model="markdown"
class="flex-1"
/>
<pre class="flex-1">{{ ast }}</pre>
<pre class="flex-1">{{ md }}</pre>
</div>
Expand Down
4 changes: 2 additions & 2 deletions playground/server/api/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Secondary slot value
`
export default () => markdownToAST(content)

function compiler (this: any) {
function compiler(this: any) {
this.Compiler = function (root: any) {
return root
}
}

export async function markdownToAST (markdown: string) {
export async function markdownToAST(markdown: string) {
const stream = unified().use(parse).use(mdc)

const file = await stream.use(compiler as Preset).process(markdown)
Expand Down
Loading

0 comments on commit 3cd5c5a

Please sign in to comment.