Skip to content
Snippets Groups Projects
Commit 5c1d04ac authored by Eloi Perdereau's avatar Eloi Perdereau
Browse files

setup netlify cms

parent af2fa6fa
No related branches found
No related tags found
No related merge requests found
---
short_name: clara
name: Clara Terrier
name: clara
display_name: Clara Terrier
position: Secrétaire
---
tip tap top
---
short_name: lucas
name: Lucas Schneider
name: lucas
display_name: Lucas Schneider
position: Président
---
Lulu président!
- name: Home
link: /
- name: About
link: /about.html
- name: Blog
link: /blog.html
- name: Staff
link: /staff.html
items:
- name: Home
link: /
- name: About
link: /about.html
- name: Blog
link: /blog.html
- name: Staff
link: /staff.html
<nav>
{% for item in site.data.navigation %}
<a href="{{ item.link }}" {% if page.url == item.link %}style="color: red;"{% endif %}>
{% for item in site.data.navigation.items %}
<a href="{{ site.baseurl }}{{ item.link }}" {% if page.url == item.link %}style="color: red;"{% endif %}>
{{ item.name }}
</a>
{% endfor %}
......
<!-- _layouts/author.html -->
<h1>{{ page.name }}</h1>
<h1>{{ page.display_name }}</h1>
<h2>{{ page.position }}</h2>
{{ content }}
......
......@@ -3,10 +3,22 @@
<head>
<meta charset="utf-8">
<title>{{ page.title }}</title>
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
</head>
<body>
{% include navigation.html %}
{{ content }}
<script>
if (window.netlifyIdentity) {
window.netlifyIdentity.on("init", user => {
if (!user) {
window.netlifyIdentity.on("login", () => {
document.location.href = "/admin/";
});
}
});
}
</script>
</body>
<footer>
default layout
......
......@@ -3,9 +3,9 @@
<p>
{{ page.date | date_to_string }}
{% assign author = site.authors | where: 'short_name', page.author | first %}
{% assign author = site.authors | where: 'name', page.author | first %}
{% if author %}
- <a href="{{ author.url }}">{{ author.name }}</a>
- <a href="{{ author.url }}">{{ author.display_name }}</a>
{% endif %}
</p>
......
# config.yml
backend:
name: git-gateway
branch: master # Branch to update (optional; defaults to master)
media_folder: 'assets/uploads'
collections:
- name: 'blog'
label: 'Blog'
folder: '_posts/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- {
label: 'Author',
name: 'author',
widget: 'relation',
collection: 'authors',
displayFields: [display_name],
searchFields: [display_name],
valueField: 'name',
}
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: 'authors'
label: 'Authors'
folder: '_authors/'
create: true
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'author' }
- { label: 'Short Name', name: 'name', widget: 'string' }
- { label: 'Diplay Name', name: 'display_name', widget: 'string' }
- { label: 'Position', name: 'position', widget: 'string' }
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: 'pages'
label: 'Pages'
editor:
preview: false
files:
- label: 'About Page'
name: 'about'
file: 'about.md'
fields:
- { label: 'Title', name: 'title', widget: 'hidden', default: 'about' }
- { label: 'Layout', name: 'title', widget: 'hidden', default: 'about' }
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: "config"
label: "Config"
editor:
preview: false
files:
- label: "Navigation"
name: "navigation"
file: "_data/navigation.yml"
fields:
- label: "Navigation Items"
name: "items"
widget: "list"
fields:
- {label: Name, name: name, widget: string}
- {label: Link, name: link, widget: string}
<!-- admin/index.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Content Manager</title>
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
</head>
<body>
<!-- Include the script that builds the page and powers Netlify CMS -->
<script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
</body>
</html>
......@@ -5,7 +5,7 @@ Staff
=====
{% for author in site.authors %}
[{{ author.name }}]({{ site.baseurl }}{{ author.url }})
[{{ author.display_name }}]({{ site.baseurl }}{{ author.url }})
{{ author.position }}
{{ author.content | markdownify }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment