message: feat(build): add demoUrl for existing demos in API pages
diff: @@ -3,6 +3,8 @@ import {
  buildPages
  } from '../index';
  +import fs from 'fs-extra';
  +import { join, resolve } from 'path';
  import { components } from '@ionic/docs/core.json';
  import markdownRenderer from '../markdown-renderer';
  @@ -12,13 +14,15 @@ export default {
  };
  async function getAPIPages(): Promise<Page[]> {
  - return components.map(component => {
  + const pages = components.map(async component => {
  const title = component.tag;
  const path = `/docs/api/${title.slice(4)}`;
  + const demoUrl = await getDemoUrl(component);
  const { readme, usage, props, methods, ...contents } = component;
  return {
  title,
  path,
  + demoUrl,
  body: markdownRenderer(readme, path),
  usage: renderUsage(usage, path),
  props: renderDocsKey(props, path),
  @@ -26,6 +30,7 @@ async function getAPIPages(): Promise<Page[]> {
  ...contents
  };
  });
  + return Promise.all(pages);
  }
  const renderUsage = (usage, baseUrl) => Object.keys(usage).reduce((out, key) => {
  @@ -37,3 +42,13 @@ const renderDocsKey = (items, baseUrl) => items.map(item => ({
  ...item,
  docs: markdownRenderer(item.docs, baseUrl)
  }));
  +
  +const DEMOS_PATH = resolve(__dirname, '../../../src/demos');
  +
  +const getDemoUrl = async (component) => {
  + const demoPath = `api/${component.tag.slice(4)}/index.html`;
  + const hasDemo = await fs.pathExists(join(DEMOS_PATH, demoPath));
  + if (hasDemo) {
  + return `/docs/demos/${demoPath}`;
  + }
  +};
  