npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

markdown-as-code

v1.1.0

Published

Define and maintain markdown files through code.

Downloads

45

Readme

markdown-as-code

This project allows managing Markdown files through JavaScript/TypeScript

Table of Contents

Installation

Install using npm

npm i markdown-as-code

Install using pnpm

pnpm i markdown-as-code

Install using yarn

yarn add markdown-as-code

Run tests

npm t
# or
npm run test

Run Locally

  • Run the tests
pnpm t

Examples

Document Sections

Acknowledgements

import { acknowledgementsSection } from 'markdown-as-code';

const content = acknowledgementsSection()
  .add({
    text: 'Acknowledgement',
    url: 'https://github.com',
  })
  .synthesize();

Api Reference

import { apiReferenceSection } from 'markdown-as-code';

const content = apiReferenceSection()
  .add({
    title: 'Get all items',
    httpMethod: 'GET',
    path: '/api/items',
    parameter: {
      name: 'api_key',
      type: 'string',
      description: '**Required**. Your API key',
    },
  })
  .synthesize();

Appendix

import { appendixSection } from 'markdown-as-code';

const content = appendixSection().appendContent('Test content').synthesize();

Authors

import { authorsSection } from 'markdown-as-code';

const content = authorsSection()
  .add({ githubUsername: 'JaneDoe' })
  .add({ githubUsername: 'JohnSmith' })
  .synthesize();

Content

import { contentSection, orderedList } from 'markdown-as-code';

// Create a content section with a title
const section = contentSection('Test Section');

// Add content to the section using the appendContent method
section.appendContent('Some markdown content');

// Use one of the element builders to add content
section.appendContent(orderedList(['item 1', 'item 2']));

Contributing

import { contributingSection } from 'markdown-as-code';

const content = contributingSection().synthesize();

Environment Variables

import { environmentVariablesSection } from 'markdown-as-code';

const content = environmentVariablesSection()
  .add({
    name: 'API_KEY',
    defaultValue: 'YOUR-API-KEY-HERE',
  })
  .synthesize();

Examples

import { examplesSection } from 'markdown-as-code';

const content = examplesSection()
  .add({
    title: 'Create an example section',
    description:
      'The title is defaulted to Examples but can be overridden in the constructor',
    codeblock: {
      language: 'typescript',
      code: 'const section = new Examples();',
    },
  })
  .synthesize();

Faq

import { faqSection } from 'markdown-as-code';

const content = faqSection()
  .add({
    question: 'Question 1',
    answer: 'Answer 1',
  })
  .synthesize();

Installation

import { installationSection } from 'markdown-as-code';

const content = installationSection()
  .add({
    command: 'npm i markdown-as-code',
    description: 'Install using npm',
  })
  .synthesize();

Roadmap

import { roadmapSection } from 'markdown-as-code';

const content = roadmapSection().add({ text: 'Item 1' }).synthesize();

Run Locally

import { runLocallySection } from 'markdown-as-code';

const content = runLocallySection()
  .add({
    command: 'npm t',
    description: 'Run the tests',
  })
  .synthesize();

Support

import { supportSection } from 'markdown-as-code';

const support = supportSection().appendContent('Test content').synthesize();

Table Of Contents

import { tableOfContentsSection, contentSection } from 'markdown-as-code';

const content = tableOfContentsSection({
  sections: [contentSection('Test Section')],
}).synthesize();

Documents

Markdown
import { createMarkdownDocument, ContentSection } from 'markdown-as-code';

const content = createMarkdownDocument({
  title: 'Test',
  fileName: 'test.md',
})
  .addSection(new ContentSection('Custom Section', 'Some markdown content'))
  .synthContent();
Readme
import { createReadmeDocument, ContentSection } from 'markdown-as-code';

const content = createReadmeDocument({
  title: 'Test',
  fileName: 'test.md',
})
  .addSection(new ContentSection('Custom Section', 'Some markdown content'))
  .synthContent();
Elements
Code Block
import { codeBlock } from 'markdown-as-code';

codeBlock({ language: 'typescript', code: 'const testNumber = 1' });
Heading
import { heading } from 'markdown-as-code';

heading(1, 'Heading Level 1');
heading(2, 'Heading Level 2');
heading(3, 'Heading Level 3');
heading(4, 'Heading Level 4');
heading(5, 'Heading Level 5');
heading(6, 'Heading Level 6');
Image
import { image } from 'markdown-as-code';

image('https://via.placeholder.com/150', 'Placeholder Image');
Link
import { link } from 'markdown-as-code';

link('Link Text', '');
List
import { orderedList, unorderedList, taskList } from 'markdown-as-code';

orderedList(['Item 1', 'Item 2', 'Item 3']);

unorderedList(['Item 1', 'Item 2', 'Item 3']);

taskList([
  { description: 'Task 1', complete: true },
  { description: 'Task 2', complete: false },
  { description: 'Task 3', complete: true },
]);
Mention
import { mentionPerson } from 'markdown-as-code';

mentionPerson('AllyMurray');
Quote
import { quote } from 'markdown-as-code';

quote('This is a quote');
Style
import { style } from 'markdown-as-code';

style('Bold', 'Example Bold Text');

style('Italic', 'Example Italic Text');

style('Strikethrough', 'Example Strikethrough Text');

style('Superscript', 'Example Superscript Text');

style('Subscript', 'Example Subscript Text');

style('BoldItalic', 'Example BoldItalic Text');
Table
import { table } from 'markdown-as-code';

table<'email' | 'description'>({
  rows: [
    {
      email: '[email protected]',
      description: 'Human Resources email',
    },
    {
      email: '[email protected]',
      description: 'Customer Support email',
    },
  ],
});

Authors

Acknowledgements