Metalsmith-permalinks failing to add path to metadata - metalsmith

I'm using metalsmith-permalinks with the following settings:
.use(permalinks({
pattern: ':title',
linksets: [{
match: { collection: 'blogposts' },
pattern: 'blog/:title'
}, {
match: { collection: 'portfolioposts' },
pattern: 'portfolio/:title'
}]
}))
However, logging files in the relevant collections shows that path isn't being added to their metadata:
layout: 'subpage.hbs',
title: 'Blog Post',
date: 2016-08-16T00:00:00.000Z,
excerpt: 'This post has an excerpt',
tags: [ 'test', 'test-tag', 'a-third-tag' ],
contents: <>,
mode: '0644',
stats: {},
collection: [ 'blogposts' ]
Permalinks is being called before layouts, meaning it can't be the same issue found here, and – as seen in the log – other plugins are adding metadata successfully.
My full build order is:
.use(collections({}))
.use(tags({}))
.use(permalinks({}))
.use(dateFormatter({}))
.use(markdown({}))
.use(helpers({}))
.use(layouts({}))
.use(rename({}))
And I'm running Metalsmith directly in Gulp. Any help would be greatly appreciated.

Related

how set custom env variables in renovate

I am using github actions where i am storing some secrets and they will be available as environment variables. I want to access these variables form my renovate config.js files
process.ENV.VARIABLE_NAME does not seem to work
There seems to be a PR that introduced this features but it is not document how it shall be used: https://github.com/renovatebot/renovate/pull/8321/files#
Here is my renovate-config.js file:
module.exports = {
platform: 'github',
logLevel: 'debug',
labels: ['renovate', 'dependencies', 'automated'],
onboarding: true,
onboardingConfig: {
extends: ['config:base', 'disableDependencyDashboard']
},
cacheDir: "/tmp/renovate",
renovateFork: true,
gitAuthor: "renovate <renovate#hhpv.de>",
username: "Renovate",
onboarding: false,
printConfig: true,
requireConfig: false,
logLevel: "DEBUG",
baseBranches: ["ecr-renovate"],
customEnvVariables: {
// what should i put here
},
hostRules: [
{
hostType: 'docker',
matchHost: '123456456.dkr.ecr.eu-central-1.amazonaws.com',
//username: process.env.AWS_ACCESS_KEY,
//password: process.env.AWS_SECRET_KEY
},
],
};
It seems renovate does not understand environment variables inside its config file, at least I could not find a working example, too.
You can however provide parts of the renovate config as environment variables, where other environment variables can be resolved.
In my case I had to provide an access token for a private maven repository, and this is what I did in my gitlab-ci.yml:
variables:
RENOVATE_HOST_RULES: '[{"matchHost": "https://gitlab.company.com/api/v4/groups/myprojectgroup/-/packages/maven", "token": "$CI_JOB_TOKEN"}]'
If you take a look into renovates debug log you should find an entry like this when the config is picked up:
"msg":"Adding token authentication for https://gitlab.company.com/api/v4/groups/myprojectgroup/-/packages/maven to hostRules","time":"2022-12-02T12:59:54.402Z","v":0}

How to set url filter in mod-header

I am trying to edit request headers and using modheader chrome extension. I use the following code, the question is how to set 'filters: []' here:
page.visit("chrome-extension://idgpnmonknjnojddfkpgkljpfnnfcklj/_generated_background_page.html")
json = JSON.generate([{title: 'Selenium', hideComment: true, appendMode: '',
headers: [{ enabled: true, name: 'name', value: 'value'}],
respHeaders: [],
filters: []
}])
page.execute_script "chrome.storage.local.set({'profiles': #{json}})"

How to use has object when rewriting url in Next.js?

This is how I use has object, but it has no effect. Why? When I remove has rewrite` will work out.
{
source: '/:organizationShortId/:postId/:tempUserShortId/:imgId',
has: [
{
type: 'header',
key: 'User-Agent',
value: 'facebook*',
},
],
destination:
'https://t44-post-cover.s3.eu-central-1.amazonaws.com/:imgId-patch',
permanent: false,
},
I expect User-Agent will be a substring of facebook.
https://developers.facebook.com/docs/sharing/webmasters/crawler/
Crawler IPs and User Agents
The Facebook crawler user agent strings:
facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
facebookexternalhit/1.1
facebookcatalog/1.0

xdmOptions with remark-disable-tokenizers to disable "indented codeblock"

I'm creating a blog using Next.js + MDX-Bundler and trying to use remark-disable-tokenizers to disable "indented codeblock". But i'm not able to make it work. I found a reference here which says that we can use remark-disable-tokenizers for this purpose.
Here is my xdmoptions for reference:
import disableTokens from 'remark-disable-tokenizers';
xdmOptions(options) {
options.rehypePlugins = [
...(options.rehypePlugins ?? []),
rehypeSlug,
rehypeCodeTitles,
rehypePrism,
[disableTokens,
{
block: [
['indentedCode', 'indented code is not supported by MDX-Bundler']
]
}],
[
rehypeAutolinkHeadings,
{...}
]
];
return options;
},

Did Firebase Cloud Functions ESLint change recently?

I created a cloud function project with firebase a few months ago, and used linting.
I recently created a new cloud function project with linting, and now the linter is complaining about random rules I never set. I don't remember it enforcing nearly the amount of style rules a few months ago.
Things like:
This line has a length of 95. Maximum allowed is 80
Missing JSDoc comment
Missing Trailing comma
expected indentation of 2 spaces but found 4
Strings must use singlequote
It's also not letting me use async/await.
I found out I can individually set these rules in my .eslintrc.js file, but that's annoying and I don't want to do that. By default, why aren't these rules disabled? I just want basic rules that make sure my code won't fail when run, not random style preferences like single/double quotes and max line length.
Is there any way to use just basic linting functionality with firebase functions?
I ran into the same issue as you. The new, more strict linting rules seem to come from the fact that Firebase functions use the "google" eslint base configuration plugin by default now. Read more about configuring ESLint plugins in the docs. My older Firebase functions were using tslint without issue.
Here's what my .eslintrc.js file looked like while I was getting style errors from eslint:
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'google',
],
parser: '#typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.dev.json'],
sourceType: 'module',
},
ignorePatterns: [
'/lib/**/*', // Ignore built files.
],
plugins: ['#typescript-eslint', 'import'],
rules: {
quotes: ['error', 'double'],
},
};
I deleted 'google' from the extends property, which seemed to resolve almost all of the style linting issues.
Now it looks like this:
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
parser: '#typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.dev.json'],
sourceType: 'module',
},
ignorePatterns: [
'/lib/**/*', // Ignore built files.
],
plugins: ['#typescript-eslint', 'import'],
rules: {
quotes: ['error', 'double'],
},
};
You can get rid of the google extends value but I would suggest keeping it and just turning off the rules that bother you the most, which for me is indentation and max length (of lines):
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
rules: {
"quotes": ["error", "double"],
"indent": ["off"],
"max-len": ["off"],
},
};
For anyone who is confused by this, there is a lint config file in the Cloud Functions folder that you can edit. As of this answer, that file is named .eslintrc.js.

Resources