-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 70d152e
Showing
35 changed files
with
3,475 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const pluginWebc = require("@11ty/eleventy-plugin-webc"); | ||
const markdownIt = require("markdown-it"); | ||
const markdownItAttrs = require("markdown-it-attrs"); | ||
const { DateTime } = require("luxon"); | ||
|
||
module.exports = function(eleventyConfig) { | ||
eleventyConfig.addPlugin(pluginWebc, { | ||
components: "src/_includes/components/*.webc" | ||
}); | ||
|
||
eleventyConfig.addPassthroughCopy("src/assets"); | ||
|
||
eleventyConfig.addJavaScriptFunction("postDate", (dateObj) => { | ||
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_SHORT); | ||
}); | ||
|
||
eleventyConfig.addJavaScriptFunction("url", (subUrl) => { | ||
if (!subUrl.startsWith('/')) subUrl = '/' + subUrl; | ||
return "https://code-crumbs.pplaissy.fr" + subUrl; | ||
}); | ||
|
||
// eleventyConfig.addJavaScriptFunction("currentYear", () => { | ||
// return DateTime.now().year; | ||
// }); | ||
|
||
eleventyConfig.addCollection("posts", function(collectionApi) { | ||
return collectionApi.getFilteredByTag("published").sort(function(a, b) { | ||
return b.date - a.date; // sort by date - descending | ||
}); | ||
}); | ||
|
||
let options = { | ||
html: true, | ||
breaks: true, | ||
linkify: true | ||
}; | ||
|
||
// set an instance of markdownIt | ||
const md = new markdownIt(options).use(markdownItAttrs); | ||
// declare a default link renderer | ||
const defaultLinkRender = md.renderer.rules.link_open || function (tokens, idx, options, env, self) { | ||
return self.renderToken(tokens, idx, options); | ||
}; | ||
// set custom render function | ||
md.renderer.rules.link_open = (tokens, idx, options, env, self) => { | ||
const token = tokens[idx]; | ||
// get the class attribute | ||
const classAttr = token.attrGet("class"); | ||
// if class attribute exists and contains the external link flag... | ||
if (classAttr && classAttr.split(' ').includes("xlk")) { | ||
// ...add the custom attributes | ||
tokens[idx].attrSet('target', '_blank'); | ||
tokens[idx].attrJoin("rel", "noopener noreferrer"); | ||
} | ||
|
||
// Pass the token to the default renderer. | ||
return defaultLinkRender(tokens, idx, options, env, self); | ||
}; | ||
|
||
md.renderer.rules.image = function (tokens, idx, options, env, self) { | ||
const token = tokens[idx]; | ||
let src = token.attrGet('src'); | ||
|
||
// truncate paths for local images | ||
token.attrSet('src', src.slice(3)); | ||
token.attrSet('alt', token.content); | ||
|
||
return self.renderToken(tokens, idx, options) | ||
}; | ||
|
||
// pass the markdown instance to eleventy config | ||
eleventyConfig.setLibrary("md", md); | ||
|
||
return { | ||
dir: { | ||
input: "src", | ||
output: "_site", | ||
includes: "_includes", | ||
layouts: "_includes/layouts" | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
name: build 11ty site | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
- name: Install dependencies & build | ||
run: | | ||
npm install | ||
npx @11ty/eleventy | ||
- uses: actions/upload-pages-artifact@v3 | ||
|
||
# Deploy the Static Site to Public Repo (GitHub Pages) | ||
- name: Deploy | ||
uses: JamesIves/[email protected] | ||
with: | ||
token: ${{ secrets.SECRETNAME }} | ||
repository-name: pplaissy/code-crumbs-site | ||
branch: main # The branch the action should deploy to. | ||
folder: _site # The folder the action should deploy. | ||
single-commit: true | ||
commit-message: "Deploy by source" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/_site |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# code-crumbs | ||
A tiny eleventy/webc static blog site | ||
[code-crumbs](https://pplaissy.github.io/code-crumbs/) |
Oops, something went wrong.