How to edit Hugo content files directly in content root folder - netlify

I am new to netlify and netlifyCMS. Did upload a Hugo site which is working well. Now trying to implement CMS. It is a very simple site with only a few *.md content files located directly in the root of the /content folder. How do I need to configure the config.yml so that I can edit them? I did only find how to edit collections in subfolders of /content or single files.
Thank you
Best regards

I think I did find a solution. Did add every content-file as a single file.
collections: # A list of collections the CMS should be able to edit
- label: "Inhalt"
name: "inhalt"
files:
- label: "Home"
name: "home"
file: "/content/home.md"
fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string"}
- {label: "Body", name: "body", widget: "markdown"}
- label: "TCM"
name: "tcm"
file: "/content/tcm.md"
fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string"}
- {label: "Body", name: "body", widget: "markdown"}
- label: "Psycho"
name: "psycho"
file: "/content/psycho.md"
fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string"}
- {label: "Body", name: "body", widget: "markdown"}

Related

Meta data keeps showing as "## Build Setup" for every page in Vuejs/Nuxt?

I've added individual meta to every page following the Nuxt documentation but whenever I share my links on social media, the meta just show this '## build setup'. Another issue is the same metadata is showing for every page. I read you need to put "hids" to have individual page meta but nothing seems to be working?
Index Meta:
<script>
export default {
head: {
title: 'Animal Crossing Portal | The Best Tier Lists for Animal Crossing',
meta: [
{ property: 'og:description', hid: 'og:description', name: 'og:description', content: 'Vote monthly in Animal Crossing Tier Lists for New Horizons & Pocket Camp! Including Villager Tier Lists, Sanrio, Gyroids & more at Animal Crossing Portal!' },
{ name: 'twitter:title', hid: 'twitter:title', content: 'Animal Crossing Portal | The Best Tier Lists for Animal Crossing' },
{ name: 'twitter:description', hid: 'twitter:description', content: 'Vote monthly in Animal Crossing Tier Lists for New Horizons & Pocket Camp! Including Villager Tier Lists, Sanrio, Gyroids & more at Animal Crossing Portal!' },
{ name: 'twitter:card', hid: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:image:src', hid: 'twitter:image:src', content: 'https://www.animalcrossingportal.com/images/meta.jpg' },
{ property: 'og:title', hid: 'og:title', name: 'og:title', content: 'Animal Crossing Portal | The Best Tier Lists for Animal Crossing' },
{ property: 'og:type', hid: 'og:type', content: 'website' },
{ property: 'og:site_name', hid: 'og:site_name', content: 'Animal Crossing Portal' },
{ property: 'og:url', hid: 'og:url', content: 'https://www.animalcrossingportal.com/' },
{ property: 'og:image', hid: 'og:image', content: 'https://www.animalcrossingportal.com/images/meta.jpg' }
],
link: [
{
rel: 'canonical',
href: 'https://www.animalcrossingportal.com/'
}
]
}
}
</script>
My nuxt.config.js file has:
head: {
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
}
The meta was actually lying inside of a README.md file, removing it from there fixed OP's issue!
I thought it was the readme file, but after a few hours of digging (issue resurfaced), turns out it was actually an empty build tag in the nuxt config file which was making Nuxt try SSR. Removing the empty tag 100% fixed it.
I was running into the same issue recently. After having a look into the source code view of the rendered page (Ctrl + U in the browser), a quick search yielded that the meta-field og:description was not populated correctly. Correction of that was straightforward.
Thus, a look on your rendered page source code might reveal the missing/wrongly populated field (e.g. "description").

Is there any way to exclude null properties when using Groovy's YAMLBuilder?

I'm using Groovy to generate an openapi spec document in YAML. I'm using YamlBuilder to convert the object model to a YAML string.
It's been working well so far, but one issue I've noticed is that null properties are present in the YAML output. This is causing validation errors in the openapi validators I'm using, so I'd like to remove any null properties from the YAML output.
Is there any way to achieve this? I can't see it in the docs. The equivalent JSONBuilder allows config options to be set, is there such a thing for YamlBuilder?
The part of the script which generates the YAML looks like this:
def generateSpec() {
println "============================\nGenerating Customer SPI spec\n============================"
def components = generateComponents()
def paths = generatePaths()
def info = Info
.builder()
.title('Customer SPI')
.description('A customer API')
.version('0.1')
.build()
def customerSpec = [openapi: "3.0.3", components : components, info : info, paths : paths]
def yaml = new YamlBuilder()
yaml(customerSpec)
println(yaml.toString())
return yaml.toString()
}
Here's my current output. Note the null value of the format property on firstname, among others.
---
openapi: "3.0.3"
components:
schemas:
Customer:
type: "object"
properties:
firstname:
type: "string"
format: null
ArrayOfCustomers:
items:
$ref: "#/components/schemas/Customer"
info:
title: "Customer SPI"
version: "0.1"
description: "An API."
paths:
/customers:
parameters: null
get:
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/ArrayOfCustomers"
description: "An array of customers matching the search criteria"
summary: "Search customers"
/customers/{customerRef}:
parameters:
- required: true
schema:
type: "string"
format: null
description: "Customer reference"
in: "path"
name: "customerRef"
get:
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/Customer"
description: "A customer with the given reference"
summary: "Load a customer"

Get the list of records to which a file is Attached

I want to get the list of all the records(whether it may be entity record, transaction record or any other record) to which a single file is attached from the file cabinet in Netsuite. Is there any way to do so??
I believe the saved search approach is the best way. But I don't think you can do it by creating a Document saved search. I think you have to create an entity saved search, a transaction saved search, etc, and then put in the file ID into the criteria filter's "File fields..." internal ID field.
Having to create a saved search for each record type is a bit clunky, but if you have SuiteScript experience it helps if you have the "NetSuite: Search Export" chrome extension. You can create one saved search on the front-end and then use that extension to "Export as script" the one saved search and try to reproduce its criteria for each record type that you are interested in linking to the one file.
Let suppose you want to search a file for a Salesorder. You need to do it separate for entity, transaction etc, remove type and id for all records search.
Here is an example in 2.0.
var salesorderSearchObj = search.create({
type: "salesorder",
filters:
[
["type","anyof","SalesOrd"],
"AND",
["internalid","anyof",12345],
"AND",
["taxline","is","F"],
"AND",
["cogs","is","F"],
"AND",
["shipping","is","F"],
"AND",
["mainline","is","T"]
],
columns:
[
search.createColumn({
name: "trandate",
sort: search.Sort.ASC,
label: "Date"
}),
search.createColumn({
name: "internalid",
join: "file",
label: "Internal ID"
}),
search.createColumn({
name: "url",
join: "file",
label: "URL"
}),
search.createColumn({
name: "url",
join: "lineFile",
label: "URL"
})
]
});
var searchResultCount = salesorderSearchObj.runPaged().count;
salesorderSearchObj.run().each(function(result){
var fileId = result.getValue({
name: "internalid",
join: "file",
label: "Internal ID"
});
var fileObj = file.load({id: fileId});
return true;
});

Collections in Hugo data file using Netlify CMS

I'm trying to get my head round using Netlify CMS with Hugo ssg.
I use:
netlify-cms#1.0
hugo#0.29
I have a simple netlify-cms config.yml with two collections: posts and authors.
backend:
name: github
repo: sebhewelt/atlas
branch: master
display_url: https://mypage.com
publish_mode: editorial_workflow
media_folder: "static/uploads"
public_folder: "/uploads"
collections:
- label: "Posts"
name: "post"
folder: "content"
create: true
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Publish Date", name: "date", widget: "datetime" , format: "YYYY-MM-DD hh:mma"}
- { label: "Body", name: "body", widget: "markdown" }
- label: "Authors"
name: "author"
folder: "data"
create: true
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "About", name: "about", widget: "string"}
The docs distinguish two collection types, of which I assume i should choose file collection, as I'd like to hold the authors data in one file.
I'd like to be able to add authors via admin dashboard and save it to file in data folder. The docs doesn't provide an example of how should the file holding the authors look like (Or does the cms make it automatically?).
I encounter an error with my current config. When I'm saving the "New Author" i get this:
Failed to persist entry: Error: Collection must have a field name that
is a valid entry identifier
Why do i get this error?
Your authors file needs to be under a top-level collection. Also, if you want to be able to add multiple authors to the file, you need to wrap the "name" and "about" widgets in a "list" type widget.
Example:
collections:
- label: "Settings"
name: "settings"
files:
- name: "authors"
label: "Authors"
file: "data/authors.yml"
extension: "yml"
fields:
- label: "Author"
name: "author"
widget: "list"
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "About", name: "about", widget: "string"}
CMS docs for file collections: https://www.netlifycms.org/docs/collection-types/#file-collections
CMS docs for list widgets: https://www.netlifycms.org/docs/widgets/#list

Add widget without it showing up in Netlify CMS preview

Is there a backend widget type which allows the user to enter a text value, in the editor but not displayed in the preview to the right?
I have this configuration from the example out of the box:
- label: "Blog"
name: "blog"
folder: "_posts/blog"
create: true
fields:
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Featured Image", name: "thumbnail", widget: "image"}
- {label: "Body", name: "body", widget: "markdown"}
I do not want the publish date to show up in the preview.
Netlify CMS allows for the preview to be custom and include or exclude anything you would like in the preview. Mimic your page layout and use the style sheet from your build to give a WYSIWYG layout.
Click here for Custom Preview Template docs
You might have something like the following in your index.html in the CMS folder
<script>
var PostPreview = createClass({
render: function() {
var entry = this.props.entry;
var image = entry.getIn(['data', 'thumbnail']);
var imageContainer = (image) ? h('section', {className: "mdc-card__media", style: {backgroundImage: `url(${image})`, height: '20rem'}},) : h('div');
return h('div', {},
h('div', { className: "blog-post" },
imageContainer,
h('div', { },
h('h1', { },
h('span', { }, entry.getIn(['data', 'title']))
),
),
h('div', {className: "post-body"},
h('div', { }, this.props.widgetFor('body'))
)
)
)
}
});
CMS.registerPreviewTemplate("blog", PostPreview);
</script>
Make sure to include the script above AFTER the cms.js script link

Resources