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
name: Clara Terrier display_name: Clara Terrier
position: Secrétaire position: Secrétaire
--- ---
tip tap top tip tap top
--- ---
short_name: lucas name: lucas
name: Lucas Schneider display_name: Lucas Schneider
position: Président position: Président
--- ---
Lulu président! Lulu président!
- name: Home items:
link: / - name: Home
- name: About link: /
link: /about.html - name: About
- name: Blog link: /about.html
link: /blog.html - name: Blog
- name: Staff link: /blog.html
link: /staff.html - name: Staff
link: /staff.html
<nav> <nav>
{% for item in site.data.navigation %} {% for item in site.data.navigation.items %}
<a href="{{ item.link }}" {% if page.url == item.link %}style="color: red;"{% endif %}> <a href="{{ site.baseurl }}{{ item.link }}" {% if page.url == item.link %}style="color: red;"{% endif %}>
{{ item.name }} {{ item.name }}
</a> </a>
{% endfor %} {% endfor %}
......
<!-- _layouts/author.html --> <!-- _layouts/author.html -->
<h1>{{ page.name }}</h1> <h1>{{ page.display_name }}</h1>
<h2>{{ page.position }}</h2> <h2>{{ page.position }}</h2>
{{ content }} {{ content }}
......
...@@ -3,10 +3,22 @@ ...@@ -3,10 +3,22 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{{ page.title }}</title> <title>{{ page.title }}</title>
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
</head> </head>
<body> <body>
{% include navigation.html %} {% include navigation.html %}
{{ content }} {{ content }}
<script>
if (window.netlifyIdentity) {
window.netlifyIdentity.on("init", user => {
if (!user) {
window.netlifyIdentity.on("login", () => {
document.location.href = "/admin/";
});
}
});
}
</script>
</body> </body>
<footer> <footer>
default layout default layout
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<p> <p>
{{ page.date | date_to_string }} {{ 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 %} {% if author %}
- <a href="{{ author.url }}">{{ author.name }}</a> - <a href="{{ author.url }}">{{ author.display_name }}</a>
{% endif %} {% endif %}
</p> </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 ...@@ -5,7 +5,7 @@ Staff
===== =====
{% for author in site.authors %} {% for author in site.authors %}
[{{ author.name }}]({{ site.baseurl }}{{ author.url }}) [{{ author.display_name }}]({{ site.baseurl }}{{ author.url }})
{{ author.position }} {{ author.position }}
{{ author.content | markdownify }} {{ 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