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

nuxt-cms-engine

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-cms-engine - npm Package Compare versions

Comparing version 2.0.23 to 2.1.0

4

lib/core/utils.d.ts

@@ -1,2 +0,2 @@

import {ICms, ICmsLayout, ICmsPage} from "../../types";
import {ICms, ICmsLayout, ICmsPage, ICmsRoute, ICmsStructure} from "../../types";

@@ -10,4 +10,6 @@ declare class CmsEngineUtils {

static getDefaultCmsLayout (): ICmsLayout;
static getDefaultCmsStructure (): ICmsStructure;
static toUrl (url: ICmsRoute): string
}
export default CmsEngineUtils;

@@ -0,1 +1,5 @@

function checkIsObject (value) {
return !(value instanceof Date) && !Array.isArray(value) && !Object.is(value, null) && !Object.is(value, undefined) && !(value instanceof Function)
}
export default class CmsEngineUtils {

@@ -135,2 +139,81 @@ /**

}
/**
* @returns {ICmsStructure}
*/
static getDefaultCmsStructure () {
return {
component: '',
data: {},
css: {
styles: {}
}
}
}
/**
*
* @param {ICmsRoute} route
* @return {ICmsRoute}
*/
static toUrl (route) {
const isString = typeof route === 'string'
if (!checkIsObject(route) && !isString) {
throw new Error('route must be a string or object')
}
if (isString) {
return route
}
let urlResult = '/'
const pathSplit = route.path.split('/')
const partsLength = pathSplit.length
const hasParams = checkIsObject(route.params) && Boolean(Object.keys(route.params).length)
pathSplit.forEach((part, index) => {
if (part === '') {
return
}
const firstChar = part.charAt(0)
if (firstChar !== '' && firstChar !== ':') {
urlResult += part
} else if (firstChar === ':') {
const clearParamKey = part.slice(1)
urlResult += hasParams ? route.params[clearParamKey] : undefined
}
if (index < partsLength - 1) {
urlResult += '/'
}
})
const queryParams = new URLSearchParams()
if (checkIsObject(route.query) && Object.keys(route.query).length) {
for (const queryParamsKey in route.query) {
if (Array.isArray(queryParams[queryParamsKey])) {
queryParams[queryParamsKey].forEach((value) => {
queryParams.append(queryParamsKey, value)
})
} else {
queryParams.append(queryParamsKey, String(route.query[queryParamsKey]))
}
}
}
const queryString = queryParams.toString()
if (queryString) {
urlResult += `?${queryString}`
}
return urlResult
}
}
import {options} from "./src/options";
import {cmsEngineStore} from "./src/store";
import CmsEngineUtils from "./core/utils";

@@ -55,3 +56,5 @@ const cmsEngine = () => {

inject('cmsEngine', cmsEngine())
inject('cmsUrl', CmsEngineUtils.toUrl)
}
{
"name": "nuxt-cms-engine",
"version": "2.0.23",
"version": "2.1.0",
"description": "CMS engine for nuxt framework",

@@ -5,0 +5,0 @@ "keywords": [

import {Module} from "@nuxt/types";
import CmsEngineUtils from "../lib/core/utils";
export type ICmsRoute = string | {
path: string,
params: Record<string, string | number>,
query: Record<string, string | string[] | number>
}
export type ICmsColors = Record<string, string>

@@ -104,7 +111,8 @@

type CmsUrl = typeof CmsEngineUtils.prototype.toUrl
declare module '@nuxt/vue-app' {
interface Context {
$cmsEngine: CmsEngine
$cmsUrl: CmsUrl
}

@@ -114,2 +122,3 @@

$cmsEngine: CmsEngine
$cmsUrl: CmsUrl
}

@@ -122,2 +131,3 @@ }

$cmsEngine: CmsEngine
$cmsUrl: CmsUrl
}

@@ -127,2 +137,3 @@

$cmsEngine: CmsEngine
$cmsUrl: CmsUrl
}

@@ -134,2 +145,3 @@ }

$cmsEngine: CmsEngine
$cmsUrl: CmsUrl
}

@@ -141,3 +153,4 @@ }

$cmsEngine: CmsEngine
$cmsUrl: CmsUrl
}
}
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