New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nuxt/content

Package Overview
Dependencies
Maintainers
4
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxt/content - npm Package Compare versions

Comparing version

to
1.10.0

types/parsers/base.d.ts

19

CHANGELOG.md

@@ -6,2 +6,21 @@ # Change Log

# [1.10.0](https://github.com/nuxt/content/compare/@nuxt/content@1.9.0...@nuxt/content@1.10.0) (2020-10-12)
### Bug Fixes
* avoid registering `components/global` when not exists ([#548](https://github.com/nuxt/content/issues/548)) ([843a5f9](https://github.com/nuxt/content/commit/843a5f9d26af68d1d29c448e58fdc7991778ed05))
* Included types folder in files ([#525](https://github.com/nuxt/content/issues/525)) ([a42e866](https://github.com/nuxt/content/commit/a42e866df271b371767338d732cb54b45fd452db))
* Incorrect type for fetch which returns a promise ([#518](https://github.com/nuxt/content/issues/518)) ([c20345a](https://github.com/nuxt/content/commit/c20345af3b30fd12b951133457348c3fbc988132))
* **content:** fix tab key handling of editor component with IME ([#509](https://github.com/nuxt/content/issues/509)) ([c5c5e02](https://github.com/nuxt/content/commit/c5c5e02497f761f59a8299f3d54ab9b54abe77eb))
### Features
* **content:** handle json arrays ([#486](https://github.com/nuxt/content/issues/486)) ([f29daac](https://github.com/nuxt/content/commit/f29daac5dfdcd79d2401522e31b69bd39ea75f32))
# [1.9.0](https://github.com/nuxt/content/compare/@nuxt/content@1.8.1...@nuxt/content@1.9.0) (2020-09-15)

@@ -8,0 +27,0 @@

86

lib/database.js

@@ -114,11 +114,18 @@ const { join, extname } = require('path')

async insertFile (path) {
const item = await this.parseFile(path)
const items = await this.parseFile(path)
if (!item) {
if (!items) {
return
}
await this.callHook('file:beforeInsert', item)
// Assume path is a directory if returning an array
if (items.length > 1) {
this.dirs.push(this.normalizePath(path))
}
this.items.insert(item)
for (const item of items) {
await this.callHook('file:beforeInsert', item)
this.items.insert(item)
}
}

@@ -131,18 +138,20 @@

async updateFile (path) {
const item = await this.parseFile(path)
const items = await this.parseFile(path)
if (!item) {
if (!items) {
return
}
await this.callHook('file:beforeInsert', item)
for (const item of items) {
await this.callHook('file:beforeInsert', item)
const document = this.items.findOne({ path: item.path })
const document = this.items.findOne({ path: item.path })
logger.info(`Updated ${path.replace(this.cwd, '.')}`)
if (document) {
this.items.update({ $loki: document.$loki, meta: document.meta, ...item })
return
logger.info(`Updated ${path.replace(this.cwd, '.')}`)
if (document) {
this.items.update({ $loki: document.$loki, meta: document.meta, ...item })
return
}
this.items.insert(item)
}
this.items.insert(item)
}

@@ -192,6 +201,9 @@

})[extension]
// Collect data from file
let data = {}
let data = []
try {
data = await parser(file.data)
// Force data to be an array
data = Array.isArray(data) ? data : [data]
} catch (err) {

@@ -201,12 +213,7 @@ logger.warn(`Could not parse ${path.replace(this.cwd, '.')}:`, err.message)

}
// Normalize path without dir and ext
const normalizedPath = this.normalizePath(path)
// Extract dir from path
const split = normalizedPath.split('/')
const dir = split.slice(0, split.length - 1).join('/')
// Overrides createdAt & updatedAt if it exists in the document
const existingCreatedAt = data.createdAt && new Date(data.createdAt)
const existingUpdatedAt = data.updatedAt && new Date(data.updatedAt)
// validate the existing dates to avoid wrong date format or typo
// Validate the existing dates to avoid wrong date format or typo
const isValidDate = (date) => {

@@ -216,11 +223,30 @@ return date instanceof Date && !isNaN(date)

return {
...data,
dir: dir || '/',
path: normalizedPath,
extension,
slug: split[split.length - 1],
createdAt: isValidDate(existingCreatedAt) ? existingCreatedAt : stats.birthtime,
updatedAt: isValidDate(existingUpdatedAt) ? existingUpdatedAt : stats.mtime
}
return data.map((item) => {
const paths = normalizedPath.split('/')
// `item.slug` is necessary with JSON arrays since `slug` comes from filename by default
if (data.length > 1 && item.slug) {
paths.push(item.slug)
}
// Extract `dir` from paths
const dir = paths.slice(0, paths.length - 1).join('/') || '/'
// Extract `slug` from paths
const slug = paths[paths.length - 1]
// Construct full path
const path = paths.join('/')
// Overrides createdAt & updatedAt if it exists in the document
const existingCreatedAt = item.createdAt && new Date(item.createdAt)
const existingUpdatedAt = item.updatedAt && new Date(item.updatedAt)
return {
slug,
// Allow slug override
...item,
dir,
path,
extension,
createdAt: isValidDate(existingCreatedAt) ? existingCreatedAt : stats.birthtime,
updatedAt: isValidDate(existingUpdatedAt) ? existingUpdatedAt : stats.mtime
}
})
}

@@ -227,0 +253,0 @@

@@ -14,2 +14,3 @@ const { join, resolve } = require('path')

module.exports = async function (moduleOptions) {
const { nuxt } = this
const isSSG =

@@ -73,8 +74,16 @@ this.options.dev === false &&

// Nuxt hooks
this.nuxt.hook('components:dirs', (dirs) => {
dirs.push({
path: '~/components/global',
global: true
const globalComponents = resolve(this.options.srcDir, 'components/global')
const dirStat = await fs.stat(globalComponents).catch(() => null)
if (dirStat && dirStat.isDirectory()) {
nuxt.hook('components:dirs', (dirs) => {
dirs.push({
path: '~/components/global',
global: true
})
})
})
} else {
// restart Nuxt on first component creation inside the dir
nuxt.options.watch.push(globalComponents)
}
this.nuxt.hook('generate:cache:ignore', ignore => ignore.push(relativeDir))

@@ -81,0 +90,0 @@

{
"name": "@nuxt/content",
"version": "1.9.0",
"version": "1.10.0",
"repository": "nuxt/content",

@@ -11,3 +11,3 @@ "license": "MIT",

"templates",
"types/*.d.ts"
"types"
],

@@ -18,3 +18,3 @@ "main": "lib/",

"@lokidb/loki": "^2.1.0",
"@nuxt/types": "^2.14.5",
"@nuxt/types": "^2.14.6",
"@types/js-yaml": "^3.12.5",

@@ -31,21 +31,21 @@ "@types/xml2js": "^0.4.5",

"gray-matter": "^4.0.2",
"hasha": "^5.2.0",
"hasha": "^5.2.2",
"hookable": "^4.1.2",
"html-tags": "^3.1.0",
"js-yaml": "3.14.0",
"mdast-util-to-hast": "^9.1.1",
"mdast-util-to-hast": "^10.0.0",
"mkdirp": "^1.0.4",
"node-req": "^2.1.2",
"node-res": "^5.0.1",
"p-queue": "6.6.1",
"prismjs": "^1.21.0",
"p-queue": "6.6.2",
"prismjs": "^1.22.0",
"property-information": "^5.5.0",
"rehype-raw": "^4.0.2",
"rehype-raw": "^5.0.0",
"rehype-sort-attribute-values": "^3.0.2",
"rehype-sort-attributes": "^3.0.2",
"remark-autolink-headings": "^6.0.1",
"remark-external-links": "^7.0.0",
"remark-footnotes": "^2.0.0",
"remark-external-links": "^8.0.0",
"remark-footnotes": "^3.0.0",
"remark-parse": "^8.0.3",
"remark-rehype": "^7.0.0",
"remark-rehype": "^8.0.0",
"remark-slug": "^6.0.0",

@@ -61,3 +61,3 @@ "remark-squeeze-paragraphs": "^4.0.0",

},
"gitHead": "0b6036e47f82beb61e9bcac40d829ba716d1c06b"
"gitHead": "0bfbaff7a9e5e759d94957e261e9816affc4d621"
}

@@ -80,4 +80,4 @@ import type { IContentDocument } from './content';

*/
fetch(): IContentDocument | IContentDocument[];
fetch<T>(): (T & IContentDocument) | (T & IContentDocument)[];
fetch(): Promise<IContentDocument | IContentDocument[]>;
fetch<T>(): Promise<(T & IContentDocument) | (T & IContentDocument)[]>;
}

Sorry, the diff of this file is not supported yet