Skip to content

Commit

Permalink
Adds Typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Nov 4, 2022
1 parent f8bfb6b commit 5ce04b8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -5,5 +5,5 @@ npm-debug.log*
.nyc_output
coverage.info
test/fixtures/*/build
lib
lib/*.*js
node_modules
20 changes: 20 additions & 0 deletions lib/index.d.ts
@@ -0,0 +1,20 @@
import { marked } from 'marked';
import Metalsmith from 'metalsmith';

export default initMarkdown;
export interface Options extends marked.MarkedOptions {
/**
* - Key names of file metadata to render to HTML - can be nested
*/
keys?: string[];
/**
* - Expand `*` wildcards in keypaths
*/
wildcard?: boolean;
};
/**
* A Metalsmith plugin to render markdown files to HTML
* @param {Options} [options]
* @return {import('metalsmith').Plugin}
*/
declare function initMarkdown(options?: Options): Metalsmith.Plugin;
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -29,6 +29,7 @@
"require": "./lib/index.cjs"
},
"type": "module",
"types": "lib/index.d.ts",
"files": [
"lib/*.js"
],
Expand All @@ -44,7 +45,7 @@
"lint": "eslint --fix .",
"lint:check": "eslint --fix-dry-run .",
"release": "npm run build && release-it .",
"build": "microbundle --target node --no-sourcemap -f cjs,esm",
"build": "microbundle --target node --no-sourcemap -f cjs,esm --generateTypes=false",
"test": "nyc mocha",
"pretest": "npm run build"
},
Expand Down
3 changes: 2 additions & 1 deletion test/index.cjs
Expand Up @@ -4,6 +4,7 @@ const assert = require('assert')
const equal = require('assert-dir-equal')
const Metalsmith = require('metalsmith')
const { name } = require('../package.json')
/* eslint-disable-next-line n/no-missing-require */
const markdown = require('..')
let expandWildcardKeypath
const path = require('path')
Expand All @@ -15,7 +16,7 @@ function msCommon(dir) {
describe('@metalsmith/markdown', function () {
before(function (done) {
import('../src/expand-wildcard-keypath.js').then(imported => {
expandWildcardKeypath = imported
expandWildcardKeypath = imported.default
done()
})
})
Expand Down

0 comments on commit 5ce04b8

Please sign in to comment.