This is my config.yml for Netlify CMS
backend:
name: git-gateway
branch: master
repo: franva/askwinston
commit_messages:
create: 'Create {{collection}} “{{slug}}”'
update: 'Update {{collection}} “{{slug}}”'
delete: 'Delete {{collection}} “{{slug}}”'
uploadMedia: '[skip ci] Upload “{{path}}”'
deleteMedia: '[skip ci] Delete “{{path}}”'
media_folder: static/img
public_folder: /img
publish_mode: editorial_workflow
local_backend: true
collections:
- name: "blog"
label: "Blog"
folder: "src/pages/blog"
create: true
media_folder: static/img
public_folder: /img
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "blog-post"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Description", name: "description", widget: "text", required: false}
- {label: "Featured Post", name: "featuredpost", widget: "boolean", required: false}
- {label: "Featured Image", name: "featuredimage", widget: image, required: false}
- {label: "Body", name: "body", widget: "markdown"}
- {label: "Tags", name: "tags", widget: "list"}
- name: "pages"
label: "Pages"
create: true
files:
- file: "src/pages/index.md"
label: "Landing Page"
name: "index"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "index-page"}
- {label: Title, name: title, widget: string}
- {label: Image, name: image, widget: image}
- {label: Subheading, name: subheading, widget: string}
- {label: Mainpitch, name: mainpitch, widget: object, fields: [{label: Description, name: description, widget: text}]}
- {label: Intro, name: intro, widget: object, fields: [{label: Heading, name: heading, widget: string}, {label: Description, name: description, widget: text}, {label: Blurbs, name: blurbs, widget: list, fields: [{label: Image, name: image, widget: image}, {label: Text, name: text, widget: text}]}]}
- {label: Main, name: main, widget: object, fields: [{label: Heading, name: heading, widget: string}, {label: Description, name: description, widget: text}, {label: Image1, name: image1, widget: object, fields: [{label: Image, name: image, widget: image}, {label: Alt, name: alt, widget: string}]}, {label: Image2, name: image2, widget: object, fields: [{label: Image, name: image, widget: image}, {label: Alt, name: alt, widget: string}]}, {label: Image3, name: image3, widget: object, fields: [{label: Image, name: image, widget: image}, {label: Alt, name: alt, widget: string}]}]}
- file: "src/pages/about/index.md"
label: "About"
name: "about"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "about-page"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Body", name: "body", widget: "markdown"}
As you can see that I have set the Media and Public folders to static/img and /img respectively for both root and collections level.
But when I upload a file from the admin blog editor, it still updates images to
/root/src/pages/blog/static/img rather than the /root/static/img folder.
You should remove those lines under the Blog collection :
media_folder: static/img
public_folder: /img
Related
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters."
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam#swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
name: "pet"
description: "Everything about your Pets"
externalDocs:
description: "Find out more"
url: "http://swagger.io"
name: "store"
description: "Access to Petstore orders"
name: "user"
description: "Operations about user"
externalDocs:
description: "Find out more about our store"
url: "http://swagger.io"
schemes:
"https"
"http"
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
operationId: "addPet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
"405":
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
put:
tags:
- "pet"
summary: "Update an existing pet"
description: ""
operationId: "updatePet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
"400":
description: "Invalid ID supplied"
"404":
description: "Pet not found"
"405":
description: "Validation exception"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
securityDefinitions:
petstore_auth:
type: "oauth2"
authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
flow: "implicit"
scopes:
write:pets: "modify pets in your account"
read:pets: "read your pets"
api_key:
type: "apiKey"
name: "api_key"
in: "header"
definitions:
Order:
type: "object"
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
type: "integer"
format: "int32"
shipDate:
type: "string"
format: "date-time"
status:
type: "string"
description: "Order Status"
enum:
- "placed"
- "approved"
- "delivered"
complete:
type: "boolean"
default: false
xml:
name: "Order"
Category:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Category"
User:
type: "object"
properties:
id:
type: "integer"
format: "int64"
username:
type: "string"
firstName:
type: "string"
lastName:
type: "string"
email:
type: "string"
password:
type: "string"
phone:
type: "string"
userStatus:
type: "integer"
format: "int32"
description: "User Status"
xml:
name: "User"
Tag:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Tag"
Pet:
type: "object"
required:
"name"
"photoUrls"
properties:
id:
type: "integer"
format: "int64"
category:
$ref: "#/definitions/Category"
name:
type: "string"
example: "doggie"
photoUrls:
type: "array"
xml:
name: "photoUrl"
wrapped: true
items:
type: "string"
tags:
type: "array"
xml:
name: "tag"
wrapped: true
items:
$ref: "#/definitions/Tag"
status:
type: "string"
description: "pet status in the store"
enum:
"available"
"pending"
"sold"
xml:
name: "Pet"
ApiResponse:
type: "object"
properties:
code:
type: "integer"
format: "int32"
type:
type: "string"
message:
type: "string"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"
I have an array of objects - lists[]; and an object - obj;
This is the lists array:
{
_id: new ObjectId("61840c5ce237f22a1c7a1ac7"),
name: 'list1',
content: [ 'aaaa' ],
description: 'aa',
tags: [],
lastmodified: 1,
__v: 0
},{
_id: new ObjectId("61840def80a88d1b2ffce400"),
name: 'list',
content: [ 'list!' ],
description: 'test',
tags: [],
__v: 0
}
and this is the obj object:
{
_id: new ObjectId("61840def80a88d1b2ffce400"),
name: 'list',
content: [ 'list!' ],
description: 'test',
tags: [],
__v: 0
}
Simple Question: How do I delete the object from "lists", similar to the "obj" one
You could use the JavaScript Array.filter() method to exclude the target object from the list:
const list = [{
_id: new ObjectId("61840c5ce237f22a1c7a1ac7"),
name: 'list1',
content: [ 'aaaa' ],
description: 'aa',
tags: [],
lastmodified: 1,
__v: 0
},{
_id: new ObjectId("61840def80a88d1b2ffce400"),
name: 'list',
content: [ 'list!' ],
description: 'test',
tags: [],
__v: 0
}];
const targetObj = {
_id: new ObjectId("61840def80a88d1b2ffce400"),
name: 'list',
content: [ 'list!' ],
description: 'test',
tags: [],
__v: 0
};
const filteredList = list.filter((element) => element._id !== targetObj._id);
use some sort of filtering... heres an idea.
items = [{
_id: new ObjectId("61840c5ce237f22a1c7a1ac7"),
name: 'list1',
content: [ 'aaaa' ],
description: 'aa',
tags: [],
lastmodified: 1,
__v: 0
},{
_id: new ObjectId("61840def80a88d1b2ffce400"),
name: 'list',
content: [ 'list!' ],
description: 'test',
tags: [],
__v: 0
}]
removeID = "61840def80a88d1b2ffce400"
items = [item for item in items if item['id'] != removeID]
Let's see if you can help me, because I've been like this for a few hours and I can't.
I'm doing some queries with Typeorm, and this is the situation:
I have an array of Ids: ["array1, array1, array3"]. that is, in the array an id is repeated 2 times.
The thing is that if I make a query such that:
const found = await this.find ({
where: {id: In (Ids)},
})
In found what I have is:
[
Catalog {
id: 'array1',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z },
Catalog {
id: 'array3',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z }
]
And that I need is:
[
Catalog {
id: 'array1',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z },
Catalog {
id: 'array1',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z },
Catalog {
id: 'array3',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z }
]
Another option would be to do next a method that receiving the parameters of the ID array and the object, iterate to obtain the array of objects that I need ... but I have not found the key either.
Thanks for you help
Finally, i do this:
const order: CatalogDto[] = []
for (let i = 0; i < Ids.length; i++) {
const found: CatalogDto = uniqueProduct.find(product=> product.id == Ids[i])
order.push(found)
}
where uniqueProduct is :
[
Catalog {
id: 'array1',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z },
Catalog {
id: 'array3',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z }
]
and in order I have:
[
Catalog {
id: 'array1',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z },
Catalog {
id: 'array1',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z },
Catalog {
id: 'array3',
image: 'https://image.jpg',
name: 'Article name',
description: 'Description',
price: 809,
createdAt: 2020-12-04T17:34:16.869Z,
updatedAt: 2020-12-04T17:34:16.869Z }
]
//team
const team = {
title: 'Our dedicated member',
subTitle: 'Team',
data: [
{
name: "Alax",
jobTitle: "Developer",
image: 'frontend/images/3.jpg',
social: [
{
name: 'facebook',
icon: 'fa-fw.fa.fa-facebook',
link: 'http://www.facebook.com'
},
{
name: 'twitter',
icon: 'fa-fw.fa.fa-twitter',
link: 'http://www.twitter.com'
},
{
name: 'linkedin',
icon: 'fa-fw.fa.fa-linkedin',
link: 'http://www.linkedin.com'
},
{
name: 'dribbble',
icon: 'fa-fw.fa.fa-dribbble',
link: 'http://www.dribbble.com'
}
]
},
]
}
]
}
I expect the output social name, link, icon
Full will be E.I
Name: Alax,
Title: Developer,
Image: Image,
social:
Facebook,
Twitter,
Linkedin,
Dribbble
Name: Jon
Title: Marketing
Image: Image
social:
Facebook,
Dribbble
There is sequelize auto where in you can generate generate models for SequelizeJS via the command line. I wanted to know if there is a way to auto generate api swagger documentaion in .yaml fromat based from my database using command line. Thanks . your help would really be appreaciated.
swagger api documentaion , is there a way to auto generate it instead og typing each CRUD from my database which is a hassle. Thanks
swagger: "2.0"
info:
version: 1.0.0
title: myApp1.0
description: my Application 1.0
basePath: /api/v1
tags:
- name: Examples
description: Simple example endpoints
- name: Products
description: Simple products endpoints
- name: Countries
description: Simple countries endpoints
- name: Users
description: Simple Users endpoints
- name: Specification
description: The swagger API specification
consumes:
- application/x-www-form-urlencoded
- application/json
produces:
- application/json
definitions:
ExampleBody:
type: object
title: example
required:
- name
properties:
name:
type: string
description: The example name
ProductsBody:
type: object
title: products
required:
- name
properties:
name:
type: string
description: The products name
CountriesBody:
type: object
title: countries
required:
- name
- sortname
properties:
name:
type: string
description: The countries name
sortname:
type: string
description: The countries sortname
UsersBody:
type: object
title: users
required:
- user_id
- firstname
- lastname
- about
- username
- email
- password
- last_login
- status
properties:
name:
type: string
description: The users firstname
sortname:
type: string
description: The users lastname
paths:
/examples:
get:
tags:
- Examples
description: Fetch all examples
responses:
200:
description: Returns all examples
post:
tags:
- Examples
description: Create a new example
parameters:
- name: example
in: body
description: number of items to skip
required: true
schema:
$ref: "#/definitions/ExampleBody"
responses:
200:
description: Returns all examples
/examples/{id}:
get:
tags:
- Examples
parameters:
- name: id
in: path
required: true
description: The id of the entity to retrieve
type: integer
responses:
200:
description: Return the example with the specified id
404:
description: Example not
/products:
get:
tags:
- Products
description: Fetch all products
parameters:
- name: offset
in: query
required: true
description: The offset of the pagination
type: integer
- name: limit
in: query
required: true
description: The limit of the pagination
type: integer
responses:
200:
description: "successful operation"
#security:
#- api_key: []
post:
tags:
- Products
description: Create a new example
parameters:
- name: example
in: body
description: number of items to skip
required: true
schema:
$ref: "#/definitions/ProductsBody"
responses:
200:
description: Returns all products
security:
- api_key: []
/products/{id}:
get:
tags:
- Products
parameters:
- name: id
in: path
required: true
description: The id of the entity to retrieve
type: integer
responses:
200:
description: Return the products with the specified id
404:
description: Products not
security:
- api_key: []
/countries:
get:
tags:
- Countries
description: Fetch all countries
parameters:
- name: token
in: header
required: false
description: The header token
type: string
- name: offset
in: query
required: false
description: The offset of the pagination
type: integer
- name: limit
in: query
required: false
description: The limit of the pagination
type: integer
responses:
200:
description: "successful operation"
#security:
#- api_key: []
post:
tags:
- Countries
description: Create a new Country
parameters:
- name: token
in: header
required: false
description: The header token
type: string
- name: country
in: body
description: number of items to skip
required: true
schema:
$ref: "#/definitions/CountriesBody"
responses:
200:
description: Create Country
# security:
# - api_key: []
/users:
get:
tags:
- Users
description: Fetch all users
parameters:
- name: token
in: header
required: false
description: The header token
type: string
- name: offset
in: query
required: false
description: The offset of the pagination
type: integer
- name: limit
in: query
required: false
description: The limit of the pagination
type: integer
responses:
200:
description: "successful operation"
post:
tags:
- Users
description: Create New User Accounts
parameters:
- name: Users
in: body
description: number of items to skip
required: true
schema:
$ref: "#/definitions/UsersBody"
responses:
200:
description: Create User Accounts
security:
- api_key: []
/users/{id}:
delete:
tags:
- Users
parameters:
- user_id: id
in: path
required: true
description: The id of the entity to be deleted
type: integer
responses:
200:
description: Returns a successful delete
404:
description: Error
security:
/spec:
get:
tags:
- Specification
responses:
200:
description: Return the API specification
securityDefinitions:
#petstore_auth:
# type: "oauth2"
# authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
# flow: "implicit"
# scopes:
# write:pets: "modify pets in your account"
# read:pets: "read your pets"
api_key:
type: "apiKey"
name: "api_key"
in: "header"