Skip to content

Commit

Permalink
Merge branch 'main' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
hjonin committed Sep 15, 2023
2 parents 7ab94e0 + fd847e3 commit 005773a
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 20 deletions.
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

1 change: 1 addition & 0 deletions _data/i18n/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
copied: "Copied!",
dark_theme: "Dark Theme",
display_params: "Display Parameters",
edit_this_page: "Edit this page",
filter_by_tag: "Filter by Tag:",
filtered_by: "Filtered by",
first_page: "First page",
Expand Down
1 change: 1 addition & 0 deletions _data/i18n/fr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
copied: "Copié !",
dark_theme: "Thème sombre",
display_params: "Paramètres d'affichage",
edit_this_page: "Modifier cette page",
filter_by_tag: "Filtrer par catégorie :",
filtered_by: "Filtré par",
first_page: "Première page",
Expand Down
1 change: 1 addition & 0 deletions _data/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
peertube_url: "",
github_url: "",
sourcehut_url: "",
repository_url: "https://github.com/codegouvfr/eleventy-dsfr",
language: "fr",
description: "baseline - précisions sur l‘organisation",
author: {
Expand Down
3 changes: 3 additions & 0 deletions _includes/templates/footer.njk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<li class="fr-footer__bottom-item">
<a class="fr-footer__bottom-link" href="/fr/donnees-personnelles/">{{ "personal_data" | i18n }}</a>
</li>
<li class="fr-footer__bottom-item">
<a class="fr-footer__bottom-link fr-icon-pencil-line fr-link--icon-left" href="{{ metadata.repository_url }}/blob/main/{{ page.inputPath }}">{{ "edit_this_page" | i18n }}</a>
</li>
{# <li class="fr-footer__bottom-item">
<a class="fr-footer__bottom-link" href="#">Gestion des cookies</a>
</li> FIXME Uncomment when DSFR cookie component #}
Expand Down
11 changes: 7 additions & 4 deletions content/calendar/calendar.njk
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ permalink: /calendar.ics
{% set hour = event.data.date | getHour %}
{% set minute = event.data.date | getMinute %}
{
"start": [
{{ year }}, {{ month }}, {{ day }}, {{ hour }}, {{ minute }}
],
"duration": { "minutes": {{ event.data.duration or 0 }} },
{% if hour == 0 and minute == 0 %}
"start": [ {{ year }}, {{ month }}, {{ day }} ],
"end": [ {{ year }}, {{ month }}, {{ day + 1 }} ],
{% else %}
"start": [ {{ year }}, {{ month }}, {{ day }}, {{ hour }}, {{ minute }} ],
"duration": { "minutes": {{ event.data.duration or 60 }} },
{% endif %}
"title": "{{ event.data.title }}",
"description": "{{ event.data.description }}",
"location": "{{ event.data.location }}",
Expand Down
2 changes: 1 addition & 1 deletion content/en/search-results.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ layout: layouts/base.njk
<div class="fr-container fr-py-8v">
<div class="fr-grid-row">
<div class="fr-col-12">
<h1>{{ title }}</h1>
<h1>{{ title }} “<span id="search-term"></span>”</h1>
<div class="fr-container">
<p><span id="result-count">0</span> {{ "results" | i18n }}</p>
<div class="fr-grid-row fr-grid-row--gutters fr-mb-3w" id="search-results">
Expand Down
3 changes: 2 additions & 1 deletion content/feed/feed.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# Metadata comes from _data/metadata.json
permalink: /feed/feed.xml
numberOfLatestPostsToShow: 10
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.language }}">
Expand All @@ -14,7 +15,7 @@ permalink: /feed/feed.xml
<name>{{ metadata.author.name }}</name>
<email>{{ metadata.author.email }}</email>
</author>
{% for post in collections.posts | reverse %}
{% for post in collections.posts| head(-1 * numberOfLatestPostsToShow) | reverse %}
{% set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.url) }}{% endset %}
<entry>
<title>{{ post.data.title }}</title>
Expand Down
3 changes: 2 additions & 1 deletion content/feed/json.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# Metadata comes from _data/metadata.json
permalink: /feed/feed.json
numberOfLatestPostsToShow: 10
---
{
"version": "https://jsonfeed.org/version/1.1",
Expand All @@ -14,7 +15,7 @@ permalink: /feed/feed.json
"url": "{{ metadata.author.url }}"
},
"items": [
{% for post in collections.posts | reverse %}
{% for post in collections.posts| head(-1 * numberOfLatestPostsToShow) | reverse %}
{% set absolutePostUrl = post.url | htmlBaseUrl(metadata.url) %}
{
"id": "{{ absolutePostUrl }}",
Expand Down
2 changes: 1 addition & 1 deletion content/fr/search-results.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ layout: layouts/base.njk
<div class="fr-container fr-py-8v">
<div class="fr-grid-row">
<div class="fr-col-12">
<h1>{{ title }}</h1>
<h1>{{ title }} “<span id="search-term"></span>”</h1>
<div class="fr-container">
<p><span id="result-count">0</span> {{ "results" | i18n }}</p>
<div class="fr-grid-row fr-grid-row--gutters fr-mb-3w" id="search-results">
Expand Down
4 changes: 2 additions & 2 deletions content/sitemap/sitemap.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
layout: layouts/page.njk
---
{# List every content page in the project #}
<ul>
{% for entry in collections.all %}
<ul data-pagefind-ignore>
{% for entry in collections.allSortedByPathAsc %}
{% if entry.url %}
<li><a href="{{ entry.url }}"><code>{{ entry.url }}</code></a></li>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion content/sitemap/sitemap.xml.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
{% for page in collections.all %}
{% for page in collections.allSortedByPathAsc %}
{% if page.url %}
{% set absoluteUrl %}{{ page.url | htmlBaseUrl(metadata.url) }}{% endset %}
<url>
Expand Down
7 changes: 7 additions & 0 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(pluginBundle);
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);

// Custom collections
eleventyConfig.addCollection("allSortedByPathAsc", function(collectionApi) {
return collectionApi.getAll().sort((a, b) => {
return a.inputPath.localeCompare(b.inputPath);
});
});

// Filters
eleventyConfig.addFilter("jsDateObject", function jsDateObject(dateStr, format, zone) {
return DateTime.fromFormat(dateStr, format || "yyyy-LL-dd", {zone: zone || "utc"}).toJSDate();
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Une base de code pour déployer un site/blog statique avec Eleventy et le DSFR.",
"scripts": {
"build": "npx @11ty/eleventy",
"postbuild": "npx -y pagefind --source _site/",
"postbuild": "npx pagefind --site _site/ --output-subdir \"_pagefind\"",
"build-ghpages": "npx @11ty/eleventy --pathprefix=/eleventy-dsfr/",
"start": "npx @11ty/eleventy --serve --quiet",
"debug": "DEBUG=Eleventy* npx @11ty/eleventy",
Expand All @@ -26,10 +26,10 @@
},
"homepage": "https://codegouvfr.github.io/eleventy-dsfr/",
"devDependencies": {
"@11ty/eleventy": "^2.0.0",
"@11ty/eleventy-img": "^3.0.0",
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-img": "^3.1.0",
"@11ty/eleventy-navigation": "^0.3.5",
"@11ty/eleventy-plugin-bundle": "^1.0.3",
"@11ty/eleventy-plugin-bundle": "^1.0.4",
"@11ty/eleventy-plugin-rss": "^1.2.0",
"@11ty/eleventy-plugin-syntaxhighlight": "^4.2.0",
"@gouvfr/dsfr": "^1.9.3",
Expand All @@ -38,7 +38,7 @@
"markdown-it-anchor": "^8.6.6",
"markdown-it-attrs": "^4.1.6",
"markdown-it-container": "^3.0.0",
"pagefind": "^0.12.0",
"pagefind": "^1.0.2",
"ics": "^3.2.0"
}
}
11 changes: 8 additions & 3 deletions public/js/search-results.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
(() => {
const RESULTS_PER_PAGE = 10;

const SEARCH_RESULTS_SELECTOR = "#search-results";
const SEARCH_TERM_SELECTOR = "#search-term";
const RESULT_COUNT_SELECTOR = "#result-count";
const SEARCH_RESULTS_SELECTOR = "#search-results";

const FULL_WIDTH_COL_CLASS = "fr-col-12";

const searchResultList = document.querySelector(SEARCH_RESULTS_SELECTOR);
const searchTermText = document.querySelector(SEARCH_TERM_SELECTOR);
const resultCounter = document.querySelector(RESULT_COUNT_SELECTOR);
const searchResultList = document.querySelector(SEARCH_RESULTS_SELECTOR);

const getSearchResults = async () => {
const pagefind = await import(PAGEFIND_URL);
const queryParams = new URLSearchParams(window.location.search);
const search = await pagefind.search(queryParams.get(SEARCH_PARAM));
const searchTerm = queryParams.get(SEARCH_PARAM);
searchTermText.textContent = searchTerm;
pagefind.init();
const search = await pagefind.search(searchTerm);
return search.results;
}

Expand Down

0 comments on commit 005773a

Please sign in to comment.