# code-block-pro/1.28.0/src/state/language.ts

Code Block Pro – Beautiful Syntax Highlighting, version 1.28.0. 41 lines.

- Page: https://pluginprobe.com/plugins/code-block-pro/1.28.0/code/src/state/language.ts
- Raw: https://pluginprobe.com/plugins/code-block-pro/1.28.0/raw/src/state/language.ts
- Modified: 2026-04-12T13:22:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-block-pro/1.28.0/code/src/state/language.ts#L10-L20`.

```typescript
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import type { Lang } from '../types';

type LanguageType = {
	previousLanguage: Lang;
	setPreviousLanguage: (language: Lang) => void;
	recentLanguages: Lang[];
	addRecentLanguage: (language: Lang) => void;
};
export const useLanguageStore = create<LanguageType>()(
	persist(
		devtools(
			(set, get) => ({
				previousLanguage: 'javascript' as Lang,
				setPreviousLanguage(language: Lang) {
					set({ previousLanguage: language });
					get().addRecentLanguage(language);
				},
				recentLanguages: [] as Lang[],
				addRecentLanguage(language: Lang) {
					// Limit to the last 5
					set((state) => {
						if (state.recentLanguages.includes(language)) {
							return state;
						}
						return {
							recentLanguages: [
								...(state.recentLanguages?.slice(-4) || []),
								language,
							],
						};
					});
				},
			}),
			{ name: 'Code Block Pro Language' },
		),
		{ name: 'code-block-pro-last-language' },
	),
);

```
