From 7ece66e6e58b1c9ede508f1196266ba8abe735a4 Mon Sep 17 00:00:00 2001 From: Tiago Celestino <190265+tcelestino@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:35:08 -0300 Subject: [PATCH] Settings 11yt (#54) --- .eleventy.js | 31 ------------------- .nojekyll | 0 README.md | 8 ++--- eleventy.config.js | 28 +++++++++++++++++ lib/collections/posts.js | 3 ++ lib/filters/readableDate.js | 12 +++++++ package.json | 6 +++- 404.html => src/404.html | 2 +- {_layouts => src/_layouts}/default.html | 4 +-- {_layouts => src/_layouts}/post.html | 0 {assets => src/assets/css}/main.css | 0 .../assets/css}/syntax-highlighting.css | 0 index.html => src/index.html | 2 +- .../posts}/2022/a-historia-do-reactjs.md | 0 .../posts}/2022/as-tendencias-de-2021.md | 0 .../posts}/2022/configurar-porta-nextjs.md | 0 .../posts}/2022/definicao-frontend.md | 0 .../2022/fakerjs-encerrado-por-seu-criador.md | 0 {posts => src/posts}/2022/iniciando.md | 0 .../2022/newsletters-ti-desenvolvimento.md | 0 .../posts}/2022/nextjs-developer-survey.md | 0 .../posts}/2022/novidades-javascript-2022.md | 0 .../posts}/2022/state-of-css-2021.md | 0 {posts => src/posts}/2022/state-of-js-2021.md | 0 .../posts}/2024/github-copilot-workspace.md | 0 .../posts}/2024/um-mes-desempregado.md | 0 {posts => src/posts}/posts.json | 0 27 files changed, 54 insertions(+), 42 deletions(-) delete mode 100644 .eleventy.js delete mode 100644 .nojekyll create mode 100644 eleventy.config.js create mode 100644 lib/collections/posts.js create mode 100644 lib/filters/readableDate.js rename 404.html => src/404.html (100%) rename {_layouts => src/_layouts}/default.html (83%) rename {_layouts => src/_layouts}/post.html (100%) rename {assets => src/assets/css}/main.css (100%) rename {assets => src/assets/css}/syntax-highlighting.css (100%) rename index.html => src/index.html (90%) rename {posts => src/posts}/2022/a-historia-do-reactjs.md (100%) rename {posts => src/posts}/2022/as-tendencias-de-2021.md (100%) rename {posts => src/posts}/2022/configurar-porta-nextjs.md (100%) rename {posts => src/posts}/2022/definicao-frontend.md (100%) rename {posts => src/posts}/2022/fakerjs-encerrado-por-seu-criador.md (100%) rename {posts => src/posts}/2022/iniciando.md (100%) rename {posts => src/posts}/2022/newsletters-ti-desenvolvimento.md (100%) rename {posts => src/posts}/2022/nextjs-developer-survey.md (100%) rename {posts => src/posts}/2022/novidades-javascript-2022.md (100%) rename {posts => src/posts}/2022/state-of-css-2021.md (100%) rename {posts => src/posts}/2022/state-of-js-2021.md (100%) rename {posts => src/posts}/2024/github-copilot-workspace.md (100%) rename {posts => src/posts}/2024/um-mes-desempregado.md (100%) rename {posts => src/posts}/posts.json (100%) diff --git a/.eleventy.js b/.eleventy.js deleted file mode 100644 index f74df0b..0000000 --- a/.eleventy.js +++ /dev/null @@ -1,31 +0,0 @@ -const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight'); - -module.exports = (eleventyConfig) => { - eleventyConfig.addPassthroughCopy('assets'); - - eleventyConfig.addCollection('post', (collection) => { - // reversed all collections posts - return collection.getFilteredByGlob('posts/**/*.md').reverse(); - }); - - eleventyConfig.addFilter('readableDate', (dateObj) => { - const date = new Date(dateObj); - date.setMinutes(date.getMinutes() + date.getTimezoneOffset()); - return date.toLocaleString('pt-BR', { - day: 'numeric', - month: 'long', - year: 'numeric', - }); - }); - - eleventyConfig.addPlugin(syntaxHighlight); - - return { - dir: { - input: './', - output: './_site', - layouts: './_layouts', - }, - templateFormats: ['html', 'md'], - }; -}; diff --git a/.nojekyll b/.nojekyll deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md index 46b11cb..dccf83b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -# My notes +# Bloco de Notas -Eleventy and GitHub Pages to write notes - -## Configure a publishing source - -Under Settings for GitHub Pages, use the `publish_branch` named in `.github/workflows/build.yml` as the publishing source. +Soon... diff --git a/eleventy.config.js b/eleventy.config.js new file mode 100644 index 0000000..6631dd5 --- /dev/null +++ b/eleventy.config.js @@ -0,0 +1,28 @@ +const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight'); + +module.exports = (config) => { + config.addPassthroughCopy('src/assets/images/**/*'); + config.addPassthroughCopy({ 'src/posts/images/**/*': 'assets/images/' }); + + config.addPassthroughCopy('src/assets/css/**/*'); + + config.addLayoutAlias('default', 'default.html'); + config.addLayoutAlias('post', 'post.html'); + + config.addCollection('posts', require('./lib/collections/posts')); + + config.addFilter('readableDate', require('./lib/filters/readableDate')); + + config.addPlugin(syntaxHighlight); + + return { + dir: { + input: 'src', + output: './_site', + layouts: '_layouts', + }, + templateFormats: ['md', 'njk', 'html'], + dataTemplateEngine: 'njk', + // markdownTemplateEngine: 'njk', + }; +}; diff --git a/lib/collections/posts.js b/lib/collections/posts.js new file mode 100644 index 0000000..99c3fd5 --- /dev/null +++ b/lib/collections/posts.js @@ -0,0 +1,3 @@ +module.exports = (coll) => { + return coll.getFilteredByGlob('src/posts/**/*.md').reverse(); +}; diff --git a/lib/filters/readableDate.js b/lib/filters/readableDate.js new file mode 100644 index 0000000..09f70e8 --- /dev/null +++ b/lib/filters/readableDate.js @@ -0,0 +1,12 @@ +module.exports = (date) => { + const formatedDate = new Date(date); + formatedDate.setMinutes( + formatedDate.getMinutes() + formatedDate.getTimezoneOffset() + ); + + return formatedDate.toLocaleString('pt-BR', { + day: 'numeric', + month: 'long', + year: 'numeric', + }); +}; diff --git a/package.json b/package.json index a4a4006..0742517 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,12 @@ "type": "git", "url": "git+https://github.com/tcelestino/bloco-de-notas.git" }, + "bugs": { + "url": "https://github.com/tcelestino/bloco-de-notas/issues" + }, + "homepage": "https://github.com/tcelestino/bloco-de-notas#readme", "author": "tcelestino", - "license": "ISC", + "license": "MIT", "devDependencies": { "@11ty/eleventy": "3.0.0", "@11ty/eleventy-plugin-syntaxhighlight": "5.0.0" diff --git a/404.html b/src/404.html similarity index 100% rename from 404.html rename to src/404.html index 419c102..f102839 100644 --- a/404.html +++ b/src/404.html @@ -1,8 +1,8 @@ --- +layout: default eleventyExcludeFromCollections: true title: Not Found permalink: 404.html -layout: default ---

🤷🏻‍♀️

diff --git a/_layouts/default.html b/src/_layouts/default.html similarity index 83% rename from _layouts/default.html rename to src/_layouts/default.html index 12c309f..5d334cd 100644 --- a/_layouts/default.html +++ b/src/_layouts/default.html @@ -3,7 +3,7 @@ - + Bloco de Notas por Tiago Celestino @@ -17,7 +17,7 @@

Blocos de Notas

-
{{ content }}
+
{{ content | raw }}