Compare commits

..

No commits in common. "fix/description" and "master" have entirely different histories.

14 changed files with 85 additions and 116 deletions

View File

@ -1,31 +1,27 @@
import rssPlugin from '@11ty/eleventy-plugin-rss'; const rssPlugin = require('@11ty/eleventy-plugin-rss');
import syntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight'; const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
import fs from 'fs'; const fs = require('fs');
import util from 'util'; const util = require('util')
// Import filters // Import filters
import dateFilter from './src/filters/date-filter.js'; const dateFilter = require('./src/filters/date-filter.js');
import markdownFilter from './src/filters/markdown-filter.js'; const markdownFilter = require('./src/filters/markdown-filter.js');
import w3DateFilter from './src/filters/w3-date-filter.js'; const w3DateFilter = require('./src/filters/w3-date-filter.js');
// Import transforms // Import transforms
import htmlMinTransform from './src/transforms/html-min-transform.js'; const htmlMinTransform = require('./src/transforms/html-min-transform.js');
import parseTransform from './src/transforms/parse-transform.js'; const parseTransform = require('./src/transforms/parse-transform.js');
// Import data files // Import data files
import {createRequire} from 'node:module';
const require = createRequire(import.meta.url);
// need this because of issue when using ESM : https://github.com/11ty/eleventy-dependency-tree-esm/issues/2
// This will get soon resolved
const site = require('./src/_data/site.json'); const site = require('./src/_data/site.json');
export default function(config) { module.exports = function(config) {
// Filters // Filters
config.addFilter('dateFilter', dateFilter); config.addFilter('dateFilter', dateFilter);
config.addFilter('markdownFilter', markdownFilter); config.addFilter('markdownFilter', markdownFilter);
config.addFilter('w3DateFilter', w3DateFilter); config.addFilter('w3DateFilter', w3DateFilter);
config.addFilter('dump', obj => { config.addFilter('dump', obj => {
return util.inspect(obj); return util.inspect(obj)
}); });
// Layout aliases // Layout aliases
@ -52,9 +48,11 @@ export default function(config) {
const livePosts = post => post.date <= now && !post.data.draft; const livePosts = post => post.date <= now && !post.data.draft;
const newsPosts = post => post.data.type === 'news'; const newsPosts = post => post.data.type === 'news';
const eventPosts = post => post.data.type === 'event'; const eventPosts = post => post.data.type === 'event';
config.addCollection('posts', collection => { config.addCollection('posts', collection => {
return [...collection.getFilteredByGlob('./src/posts/*.md')].reverse(); return [
...collection.getFilteredByGlob('./src/posts/*.md')
].reverse();
}); });
config.addCollection('news', collection => { config.addCollection('news', collection => {
return [ return [
@ -72,59 +70,56 @@ export default function(config) {
.slice(0, site.maxNewsPerPage); .slice(0, site.maxNewsPerPage);
}); });
config.addCollection('members', collection => { config.addCollection('members', collection => {
return [...collection.getFilteredByGlob('./src/members/*.md')]; return [...collection.getFilteredByGlob("./src/members/*.md")];
}); });
config.addCollection('profiles', collection => { config.addCollection('profiles', collection => {
return [...collection.getFilteredByGlob('./src/members/*.md')] return [...collection.getFilteredByGlob("./src/members/*.md")]
.reverse() .reverse()
.slice(0, site.maxProfilePreview); .slice(0, site.maxProfilePreview)
;
}); });
config.addCollection('tagsList', function(collectionApi) { config.addCollection("tagsList", function(collectionApi) {
const tagsList = new Set(); const tagsList = new Set();
collectionApi.getAll().map(item => { collectionApi.getAll().map( item => {
if (item.data.tags) { if (item.data.tags) { // handle pages that don't have tags
// handle pages that don't have tags item.data.tags.map( tag => tagsList.add(tag))
item.data.tags.map(tag => tagsList.add(tag)); }
}
}); });
return tagsList; return tagsList;
}); });
config.addCollection('skillsList', function(collectionApi) { config.addCollection("skillsList", function(collectionApi) {
const skillsList = new Set(); const skillsList = new Set();
collectionApi.getFilteredByGlob('./src/members/*.md').map(item => { collectionApi.getFilteredByGlob("./src/members/*.md").map( item => {
if (item.data.tags) { if (item.data.tags) { // handle pages that don't have skills
// handle pages that don't have skills item.data.tags.map( skill => { // exclude non related tags
item.data.tags.map(skill => { if (['post', 'news', 'event'].indexOf(skill) == -1) {
// exclude non related tags skillsList.add(skill)
if (['post', 'news', 'event'].indexOf(skill) == -1) { }
skillsList.add(skill); })
} }
});
}
}); });
return skillsList; return skillsList;
}); });
config.addCollection('membersLocations', function(collectionApi) { config.addCollection("membersLocations", function(collectionApi) {
return collectionApi return collectionApi.getFilteredByGlob("./src/members/*.md")
.getFilteredByGlob('./src/members/*.md')
.filter(item => typeof item.data.location !== 'undefined') .filter(item => typeof item.data.location !== 'undefined')
.map(member => { .map( member => {
return { return {
name: member.data.name, name: member.data.name,
url: member.data.url, url: member.data.url,
location: member.data.location location: member.data.location,
}; };
}); });
}); });
config.addCollection('customers', collection => { config.addCollection('customers', collection => {
return [...collection.getFilteredByGlob('./src/customers/*.md')] return [...collection.getFilteredByGlob("./src/customers/*.md")]
.reverse() .reverse()
.slice(0, site.maxCustomerPerPage); .slice(0, site.maxCustomerPerPage);
}); });
config.addCollection('partners', collection => { config.addCollection('partners', collection => {
return [...collection.getFilteredByGlob('./src/partners/*.md')] return [...collection.getFilteredByGlob("./src/partners/*.md")]
.reverse() .reverse()
.slice(0, site.maxPartnerPerPage); .slice(0, site.maxPartnerPerPage);
}); });
// Plugins // Plugins
@ -151,6 +146,6 @@ export default function(config) {
input: 'src', input: 'src',
output: 'dist' output: 'dist'
}, },
passthroughFileCopy: true passthroughFileCopy: true,
}; };
} };

View File

@ -3,7 +3,6 @@
"version": "0.1.0", "version": "0.1.0",
"description": "Site web de la coopérative Astrolabe CAE", "description": "Site web de la coopérative Astrolabe CAE",
"main": "index.js", "main": "index.js",
"type": "module",
"dependencies": { "dependencies": {
"@11ty/eleventy": "^3.0.0", "@11ty/eleventy": "^3.0.0",
"@11ty/eleventy-plugin-rss": "^2.0.2", "@11ty/eleventy-plugin-rss": "^2.0.2",

View File

@ -1,4 +1,4 @@
export default { module.exports = {
random() { random() {
const segment = () => { const segment = () => {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);

View File

@ -1,4 +1,4 @@
export default { module.exports = {
getNextHeadingLevel(currentLevel) { getNextHeadingLevel(currentLevel) {
return parseInt(currentLevel, 10) + 1; return parseInt(currentLevel, 10) + 1;
}, },

View File

@ -1,11 +1,6 @@
import {createRequire} from 'node:module';
const require = createRequire(import.meta.url);
// need this because of issue when using ESM : https://github.com/11ty/eleventy-dependency-tree-esm/issues/2
// This will get soon resolved
const tokens = require('./tokens.json'); const tokens = require('./tokens.json');
export default { module.exports = {
colors() { colors() {
let response = []; let response = [];

View File

@ -7,8 +7,8 @@
{% set pageTitle = metaTitle %} {% set pageTitle = metaTitle %}
{% endif %} {% endif %}
{% if description %} {% if metaDesc %}
{% set pageDesc = description %} {% set pageDesc = metaDesc %}
{% endif %} {% endif %}
<title>{{ pageTitle }}</title> <title>{{ pageTitle }}</title>
@ -24,10 +24,10 @@
<meta name="twitter:creator" content="@{{ site.authorHandle | replace('@', '') }}" /> <meta name="twitter:creator" content="@{{ site.authorHandle | replace('@', '') }}" />
{% endif %} {% endif %}
{% if description %} {% if metaDesc %}
<meta name="description" content="{{ description }}" /> <meta name="description" content="{{ metaDesc }}" />
<meta name="twitter:description" content="{{ description }}" /> <meta name="twitter:description" content="{{ metaDesc }}" />
<meta property="og:description" content="{{ description }}" /> <meta property="og:description" content="{{ metaDesc }}" />
{% endif %} {% endif %}
{% if socialImage %} {% if socialImage %}

View File

@ -19,7 +19,7 @@
<atom:link href="{{ permalink | htmlBaseUrl(metadata.base) }}" rel="self" type="application/rss+xml" /> <atom:link href="{{ permalink | htmlBaseUrl(metadata.base) }}" rel="self" type="application/rss+xml" />
<description>{{ metadata.description }}</description> <description>{{ metadata.description }}</description>
<language>{{ metadata.language or page.lang }}</language> <language>{{ metadata.language or page.lang }}</language>
{%- for post in collections.posts %} {%- for post in collections.news %}
{%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.base) %} {%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.base) %}
<item> <item>
<title>{{ post.data.title }}</title> <title>{{ post.data.title }}</title>

View File

@ -5,28 +5,13 @@ const appendSuffix = n => {
return n + (s[(v - 20) % 10] || s[v] || s[0]); return n + (s[(v - 20) % 10] || s[v] || s[0]);
}; };
export default function dateFilter(value) { module.exports = function dateFilter(value) {
const dateObject = new Date(value); const dateObject = new Date(value);
// const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; // const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
const months = [ const months = ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juill.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'];
'janv.',
'févr.',
'mars',
'avr.',
'mai',
'juin',
'juill.',
'août',
'sept.',
'oct.',
'nov.',
'déc.'
];
const dayWithSuffix = appendSuffix(dateObject.getDate()); const dayWithSuffix = appendSuffix(dateObject.getDate());
// return `${dayWithSuffix} ${months[dateObject.getMonth()]} ${dateObject.getFullYear()}`; // return `${dayWithSuffix} ${months[dateObject.getMonth()]} ${dateObject.getFullYear()}`;
return `${dateObject.getDate()} ${ return `${dateObject.getDate()} ${months[dateObject.getMonth()]} ${dateObject.getFullYear()}`;
months[dateObject.getMonth()] };
} ${dateObject.getFullYear()}`;
}

View File

@ -1,11 +1,9 @@
import markdownIt from 'markdown-it'; const markdownIt = require('markdown-it')({
const m = markdownIt({
html: true, html: true,
breaks: true, breaks: true,
linkify: true linkify: true
}); });
export default function markdown(value) { module.exports = function markdown(value) {
return m.render(value); return markdownIt.render(value);
} };

View File

@ -1,5 +1,5 @@
export default function w3cDate(value) { module.exports = function w3cDate(value) {
const dateObject = new Date(value); const dateObject = new Date(value);
return dateObject.toISOString(); return dateObject.toISOString();
} };

View File

@ -5,5 +5,5 @@ brandHeading: La Coopérative d'Entrepreneur·es spécialisée dans le numériqu
newsHeading: Actualité & Évenements newsHeading: Actualité & Évenements
customersHeading: Ils nous font confiance customersHeading: Ils nous font confiance
partnersHeading: Nos partenaires partnersHeading: Nos partenaires
description: 'Astrolabe CAE est une coopérative d Entrepreneur·es (scop) spécialisée dans l accompagnement au développement de projets autour des métiers du numérique. L entrepreneuriat (entrepreneur, entrepreneure, entrepreneuse, indépendant, indépendante, freelance, createur, créatrice) sans prise de tête, vous développez votre projet, vous gérez vos clients et nous faisons le reste et le tout dans un cadre coopératif (SCOP, ESS).' metaDesc: 'Astrolabe CAE est une coopérative d Entrepreneur·es (scop) spécialisée dans l accompagnement au développement de projets autour des métiers du numérique. L entrepreneuriat (entrepreneur, entrepreneure, entrepreneuse, indépendant, indépendante, freelance, createur, créatrice) sans prise de tête, vous développez votre projet, vous gérez vos clients et nous faisons le reste et le tout dans un cadre coopératif (SCOP, ESS).'
--- ---

View File

@ -1,6 +1,6 @@
import htmlmin from 'html-minifier'; const htmlmin = require('html-minifier');
export default function htmlMinTransform(value, outputPath) { module.exports = function htmlMinTransform(value, outputPath) {
if (outputPath.indexOf('.html') > -1) { if (outputPath.indexOf('.html') > -1) {
let minified = htmlmin.minify(value, { let minified = htmlmin.minify(value, {
useShortDoctype: true, useShortDoctype: true,
@ -11,4 +11,4 @@ export default function htmlMinTransform(value, outputPath) {
return minified; return minified;
} }
return value; return value;
} };

View File

@ -1,20 +1,17 @@
import {JSDOM} from '@tbranyen/jsdom'; const jsdom = require('@tbranyen/jsdom');
import minify from '../utils/minify.js'; const {JSDOM} = jsdom;
import slugify from 'slugify'; const minify = require('../utils/minify.js');
import getSize from 'image-size'; const slugify = require('slugify');
const getSize = require('image-size');
export default function(value, outputPath) { module.exports = function(value, outputPath) {
if (outputPath.endsWith('.html')) { if (outputPath.endsWith('.html')) {
const DOM = new JSDOM(value, { const DOM = new JSDOM(value, {
resources: 'usable' resources: 'usable'
}); });
const document = DOM.window.document; const document = DOM.window.document;
const articleImages = [ const articleImages = [...document.querySelectorAll('main section:not(.process-cae, .presentation, .member) article img, .intro img')];
...document.querySelectorAll(
'main section:not(.process-cae, .presentation, .member) article img, .intro img'
)
];
const articleHeadings = [ const articleHeadings = [
...document.querySelectorAll('main article h2, main article h3') ...document.querySelectorAll('main article h2, main article h3')
]; ];
@ -25,12 +22,12 @@ export default function(value, outputPath) {
image.setAttribute('loading', 'lazy'); image.setAttribute('loading', 'lazy');
const file = image.getAttribute('src'); const file = image.getAttribute('src');
if (file.indexOf('http') < 0) { if (file.indexOf('http') < 0) {
const dimensions = getSize('src' + file); const dimensions = getSize('src' + file);
image.setAttribute('width', dimensions.width); image.setAttribute('width', dimensions.width);
image.setAttribute('height', dimensions.height); image.setAttribute('height', dimensions.height);;
} }
// Replace p tags by figure tag for img // Replace p tags by figure tag for img
@ -47,7 +44,7 @@ export default function(value, outputPath) {
figCaption.innerHTML = image.getAttribute('title'); figCaption.innerHTML = image.getAttribute('title');
figure.appendChild(figCaption); figure.appendChild(figCaption);
} }
image.parentNode.replaceWith(figure); image.parentNode.replaceWith(figure);
}); });
} }
@ -89,4 +86,4 @@ export default function(value, outputPath) {
return '<!DOCTYPE html>\r\n' + document.documentElement.outerHTML; return '<!DOCTYPE html>\r\n' + document.documentElement.outerHTML;
} }
return value; return value;
} };

View File

@ -1,3 +1,3 @@
export default function minify(input) { module.exports = function minify(input) {
return input.replace(/\s{2,}/g, '').replace(/\'/g, '"'); return input.replace(/\s{2,}/g, '').replace(/\'/g, '"');
} };