Skip to content

Technical Design: Google Docs to Markdown Generator

Ethan-Strominger edited this page Nov 19, 2023 · 1 revision

Components (all in Phase 1)

  • (80%) Gdoc2MD Node Script: converts Google Docs to Markdown - writes to specified GitHub location or local folder. Uses gdoc metadata from Knowledgebase Server.
  • (80%) Knowledgebase UI Server - stores metadata for the Google Docs (gets input from 1c and 2)
  • (Not started) Gdoc2MD API node server
    • converts gdocs to md in configured folder using UI Knowledgebase Server to determine which branch to publish to (or to write locally). Potentially Phase 1 would need to manually enter the URL unless I can figure out a way to add the URL to the Knowledgebase UI.
  • Github Website Repository
  • Local file system with website for development

Integration Enhancements

  • Gdocs App Scripts to Knowledgebase - add in provides option to update gdoc metadata for the displayed gdoc
  • Gdocs App Script Web Hook to Knowledgebase - listen for Google Doc changes and call Node s
  • Gdocs App Script to Knowledge Base: add in to execute a URL that brings up the record for the current document

Draft: System Flow

  • Browser: Enter URL that calls Node Server =>
  • Node Server:
    • Creates front matter for Google Docs using database
    • Reads google docs and converts based to markdown =>
    • Option A (write to Github) or B (write to deployment server)

Option A - Write to Github

Automatically:

  • Write to github google-docs branch =>
  • Create pull request to github-pages =>
  • approve and merge pull request

Option B - write to deployment server

  • Before Jekyll is run, write to directory used as source for Jekyll on deployment

Draft: Autorun - not started

Options Google Docs hook Scheduled batch jobs

Draft: Phase 1

  • All local
  • Fork website repo, clone to local
  • Set up and configure script
  • Run script
  • reads google docs and converts
  • writes to local website git dir
  • Manually create a pull request

Draft: GDoc2MD - how it works

  • Run jekyll to create initial version of website
  • Fetch all GoogleDocs (as JSON) in specified folder and subfolders recursively
  • Create GoogleDocObjs from GoogleDocs. GoogleDocsObj has the same structure as JSON with additional methods and attributes
    • Derive a list of markdown elements from each GoogleDocsObj
    • Create markdown from markdown elements using existing npmjs package "toMarkdown"
    • Post processing
      • Derive frontmatter
      • Combine frontmatter and markdown
      • remove blank lines
      • Derive filename from Google Docs description and append "-gdoc" (so that git will ignore if website is derived directly in git).
      • Write file to specified website directory or github (v2) or google doc (could have)