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

gdocs-database

v0.1.6

Published

Use Google Docs to host your website's content

Downloads

7

Readme

pre-beta-alpha version 0.0.0.0.1 do not expect this to work or make any sense

gdocs-database

Use Google Docs to host your website's (or app's) content. See this repo for an example using Reactjs and Typescript.

Why?

Have you ever had someone you're making a website for ask you to change one word in a paragraph? Add one image to a page? These simple yet very specific tasks are what clients often most care about, and what developers least care about.

I wanted to have a way for non-developers to change and add content to their website in a way they are already familiar with. With gdocs-database, Google Docs can be used to host the parts of the website that clients should have control over, taking away unnecessary responsibility from the developer.

How?

Google Docs are exported as txt files which are then parsed into custom objects that you can use to build your view.

Installation

npm install gdocs-database

Getting Started

The basic steps are these:

  • Format a Google Doc
  • Get the public URL for the doc
  • Pass the public URL and a path to docToContent(docsUrl, filePath)
  • Read the resulting JSON file with getContent(jsonFile)
  • Write your own function to parse the resulting ContentObject array into divs for your website (see here for an example).

Google Doc Formatting

There are different types of content that can be added to the Google Doc to be displayed on your website.

  • Different types of content should be seperated by a line break.
  • Inline links should be formatted in Markdown style: [Click here!](https://<whataver-url-you-want>)
  • Media like images and videos can all just be added by putting the URL/URI on it's own line in the doc.

See this Example Google Doc, and the corresponding webpage.

Get the public Google Doc export URL

A Google Doc represents a section of content to be displayed. To get a public Google Doc URL:

  • While editing a Google Doc, click 'Share' in the top right
  • Under 'Get Link' click 'Copy link'
  • Make sure 'Anyone with the link' is set to 'Viewer', as this URL will be public

Module Exports

Classes and Types

Class Page

Used to help store information about a page of content. Properties:

  • name?: string an optional name for the page
  • path: string a path the JSON file will be written to
  • docsUrl: string the public google docs URL
Class Link

Used to represent the text and URL of a link. Properties:

  • text: string the text to click on
  • url: string the public google docs URL
Class ContentObject

Stores the data associate with content from the Google Doc. Properties:

  • contentType: ContentTypes denotes a 'type' for the content data
  • data: string | Link | Para the data
Enum ContentTypes

Defines the types of content possible

Type jsonType

The type declaration for the resulting JSON file. Useful if you want to write your own function to parse the JSON to something other than a ContentObject array.

Functions

docToContent
async function docToContent(url: string, filePath: string = TEMP_FILE_NAME): Promise<ContentObject[] | null>

Downloads a Google Doc as a text file, then parses the text file into a ContentObject array. Returns a promise of an array of ContentObjects and writes it as JSON to the file path if specified.

getContent
function getContent(json: jsonType): ContentObject[]

Parses the JSON file (resulting from a call to docToContent) to a ContentObject array. You can then write your own function to iterate through the ContentObjects and build your view.