Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

notablog

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notablog - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

assets/deps_graph.svg

40

index.js

@@ -15,3 +15,4 @@ const fs = require('fs')

const workDir = process.cwd()
const config = JSON.parse(fs.readFileSync('config.json', { encoding: 'utf-8' }))
const configPath = path.join(workDir, 'config.json')
const config = JSON.parse(fs.readFileSync(configPath, { encoding: 'utf-8' }))
const url = config.url

@@ -21,13 +22,2 @@ const theme = config.theme

const cacheDir = path.join(workDir, 'source/notion_cache')
if (!fs.existsSync(cacheDir)) {
fs.mkdirSync(cacheDir, { recursive: true })
}
const themeDir = path.join(workDir, `themes/${theme}`)
const outDir = path.join(workDir, 'public')
if (!fs.existsSync(outDir)) {
fs.mkdirSync(outDir, { recursive: true })
}
const taskManagerOpts = {

@@ -52,2 +42,18 @@ delay: 0,

/** Init dir paths. */
const cacheDir = path.join(workDir, 'source/notion_cache')
if (!fs.existsSync(cacheDir)) {
fs.mkdirSync(cacheDir, { recursive: true })
}
const themeDir = path.join(workDir, `themes/${theme}`)
if (!fs.existsSync(themeDir)) {
throw new Error(`No theme "${theme}" in themes/ folder.`)
}
const outDir = path.join(workDir, 'public')
if (!fs.existsSync(outDir)) {
fs.mkdirSync(outDir, { recursive: true })
}
/** Copy assets. */

@@ -71,5 +77,7 @@ log('Copy assets.')

index: {
// Clone one so the plugins can not change original data.
posts: blogTable.posts.map(post => { return {...post} }),
template: indexTemplate
title: blogTable.global.title,
/** Clone one so the plugin changes are local. */
posts: blogTable.posts.map(post => { return { ...post } }),
template: indexTemplate,
output: 'index.html'
},

@@ -95,3 +103,3 @@ operations: {

let cacheFilePath = path.join(cacheDir, cacheFileName)
let postUpdated

@@ -98,0 +106,0 @@ if (fs.existsSync(cacheFilePath)) {

7

package.json
{
"name": "notablog",
"version": "0.2.0",
"version": "0.2.1",
"description": "Generate a minimal blog from Notion.so.",
"main": "index.js",
"scripts": {},
"scripts": {
"build:graph": "npx depcruise --exclude '^node_modules' --output-type dot --prefix 'https://github.com/dragonman225/notablog/tree/master/' index.js | dot -T svg > assets/deps_graph.svg"
},
"repository": {

@@ -24,2 +26,3 @@ "type": "git",

"devDependencies": {
"dependency-cruiser": "^5.0.0",
"eslint": "^6.1.0"

@@ -26,0 +29,0 @@ },

@@ -5,3 +5,3 @@ # notablog

Some images. 🙂
Here are some images of my blog. 🙂 [Visit site](https://dragonman225.github.io/)

@@ -16,5 +16,7 @@ | Mobile | Desktop |

1. Duplicate my [BlogTable template](https://www.notion.so/937c97eb6efb47f5864dc7fa66bbe88a?v=7076048baf9842238b74342f6b491c5b) on Notion.
1. Duplicate my [table template](https://www.notion.so/937c97eb6efb47f5864dc7fa66bbe88a?v=7076048baf9842238b74342f6b491c5b) on Notion.
2. Make the table you've duplicated **public**.
3. Clone the [`notablog-starter`](https://github.com/dragonman225/notablog-starter) repository and install packages.
3. Clone the [`notablog-starter`](https://github.com/dragonman225/notablog-starter) repository and install it.
```bash

@@ -24,5 +26,11 @@ git clone https://github.com/dragonman225/notablog-starter.git

```
4. Open `config.json`. Change `url` field to the URL of the table you've duplicated.
5. Issue command `npm run generate`. Generated static assets are in `public` folder. You can move that folder to your hosting location.
5. Issue command `npm run generate`.
6. Generated blog is the `public` folder. You can open `public/index.html` in a browser to preview.
7. If you want to host the blog on the internet, either can you build your own server or use static hosting services like [Github Pages](https://pages.github.com/), [Netlify](https://www.netlify.com/), etc.
## Customize the Blog

@@ -118,1 +126,5 @@

| `content` | `string` | HTML string of the page, including title. |
## Project Structure
![](assets/deps_graph.svg)

@@ -19,3 +19,3 @@ const downloadPageAsTree = require('nast-util-from-notionapi')

/**
* Create map for random_string -> property_name.
* Create map for property_name -> random_string.
* Notion uses random strings in schema to prevent probable repeated

@@ -66,4 +66,3 @@ * property names defined by user.

/**
* Each `post` contains metadata needed to fetch and render a page in the
* fetch pipeline.
* Each `post` contains metadata of the post.
*/

@@ -79,3 +78,3 @@ let posts = rawTable.data

/**
* Structure of tags looks like this:
* Raw tags looks like this:
* { '<random_string>': [ [ 'css,web' ] ] }

@@ -96,4 +95,6 @@ */

: '',
/** Description is StyledString[]. */
description: row.properties[schemaMap['description']],
/** Raw description is StyledString[]. */
description: row.properties[schemaMap['description']]
? row.properties[schemaMap['description']]
: [],
createdTime: row['created_time'],

@@ -107,3 +108,3 @@ lastEditedTime: row['last_edited_time'],

/**
* Reverse the posts array so that the most recent post is at the top.
* Sort the posts so that the most recent post is at the top.
*/

@@ -110,0 +111,0 @@ return {

@@ -26,8 +26,18 @@ const { toHTMLInternal } = require('nast-util-to-html')

context.index.posts.forEach(post => {
post.description = toHTMLInternal.renderTitle(post.description)
post.descriptionHTML = renderToHTML(post.description)
post.descriptionPlainText = renderToPlainText(post.description)
})
} else if (pageType === 'post') {
context.post.description = toHTMLInternal.renderTitle(context.post.description)
context.post.descriptionHTML = renderToHTML(context.post.description)
context.post.descriptionPlainText = renderToPlainText(context.post.description)
}
}
function renderToHTML(desc) {
return toHTMLInternal.renderTitle(desc)
}
function renderToPlainText(desc) {
return desc.map(str => str[0]).join('')
}

@@ -24,6 +24,6 @@ const plugin = {

context.index.posts.forEach(post => {
post.createdTime = doTransformDate(post.createdTime)
post.createdTimeHumanReadable = doTransformDate(post.createdTime)
})
} else if (pageType === 'post') {
context.post.createdTime = doTransformDate(context.post.createdTime)
context.post.createdTimeHumanReadable = doTransformDate(context.post.createdTime)
}

@@ -30,0 +30,0 @@

@@ -30,3 +30,3 @@ const fs = require('fs')

else
log(`Plugin ${plugin.name} is not a function, skipped.`)
log(`Plugin ${plugin.name} is in wrong format, skipped.`)
})

@@ -38,3 +38,3 @@ }

const indexPath = path.join(outDir, 'index.html')
Sqrl.autoEscaping(false)

@@ -41,0 +41,0 @@ const html = Sqrl.Render(index.template, {

@@ -33,2 +33,5 @@ const fs = require('fs')

* @property {string} template
* @property {string} descriptionHTML - Plugin: `render-description`
* @property {string} descriptionPlainText - Plugin: `render-description`
* @property {string} createdTime - Plugin: `timestamp-to-date`
*/

@@ -87,3 +90,3 @@

if (_nast != null) nast = _nast
else throw new Error(`Cache of ${pageID} is corrupted.`)
else throw new Error(`Cache of ${pageID} is corrupted. Delete source/notion_cache to rebuild.`)
}

@@ -104,3 +107,3 @@

else
log(`Plugin ${plugin.name} is not a function, skipped.`)
log(`Plugin ${plugin.name} is in wrong format, skipped.`)
})

@@ -107,0 +110,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc