Skip to content

Change call order of compileOptions.permalink and compile to support MD5 hash in permalink #2786

Answered by danburzo
danburzo asked this question in Ideas
Discussion options

You must be logged in to vote

A possible workaround involves processing the SCSS file at the getData() level:

config.addTemplateFormats('scss');
config.addExtension('scss', {
	read: false,
	getData: async function(inputPath) {
		const { css } = sass.compile(inputPath);
		return {
			_content: css,
			_hash: getHash(css)
		};
	},
	compileOptions: {
		permalink: function(permalink, inputPath) {
			if (path.basename(inputPath).startsWith("_")) {
				return false;
			}
			return data => `${data.page.filePathStem}.${data._hash}.css`;
		}
	},
	compile: () => data => data._content
});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by danburzo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant